diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index bc38ce887f..802c493627 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -109,8 +109,16 @@ public class ApiAutomationController { return apiAutomationService.run(request); } + @PostMapping(value = "/run/jenkins") + public String runByJenkins(@RequestBody RunScenarioRequest request) { + request.setExecuteType(ExecuteType.Saved.name()); + request.setTriggerMode(ApiRunMode.SCENARIO.name()); + request.setRunMode(ApiRunMode.SCENARIO.name()); + return apiAutomationService.run(request); + } + @PostMapping(value = "/run/batch") - public String runBatch(@RequestBody RunScenarioRequest request) { + public String runBatcah(@RequestBody RunScenarioRequest request) { request.setExecuteType(ExecuteType.Saved.name()); request.setTriggerMode(ApiRunMode.SCENARIO.name()); request.setRunMode(ApiRunMode.SCENARIO.name()); diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index cf82dc8ea1..b64f1bb209 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -236,7 +236,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Failure.name()); } } catch (Exception e) { - LogUtil.error(e.getMessage(), e); + } } sendTask(report, reportUrl, testResult); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml index 80c68f3fbc..fd1c322000 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml @@ -75,6 +75,7 @@ + test_case_review_users and test_case.update_time @@ -368,7 +369,7 @@ UNION ALL - SELECT test_plan_api_scenario.id as reportId,test_plan_api_scenario.api_scenario_id as id,"scenario" as + SELECT test_plan_api_scenario.api_scenario_id as testId,test_plan_api_scenario.id as id,"scenario" as type,api_scenario.name,test_plan_api_scenario.status from test_plan_api_scenario left join diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java index af7fe585e1..ee0df8a47d 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java @@ -3,6 +3,7 @@ package io.metersphere.track.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.automation.*; +import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; @@ -55,6 +56,14 @@ public class TestPlanScenarioCaseController { return testPlanScenarioCaseService.run(request); } + @PostMapping(value = "/jenkins/run") + public String runByRun(@RequestBody RunScenarioRequest request) { + request.setExecuteType(ExecuteType.Saved.name()); + request.setTriggerMode(ApiRunMode.SCENARIO.name()); + request.setRunMode(ApiRunMode.SCENARIO.name()); + return testPlanScenarioCaseService.run(request); + } + @PostMapping("/batch/update/env") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) public void batchUpdateEnv(@RequestBody RelevanceScenarioRequest request) { diff --git a/backend/src/main/resources/db/migration/V78__v1.8_release.sql b/backend/src/main/resources/db/migration/V78__v1.8_release.sql index 122ecbbe44..189edde342 100644 --- a/backend/src/main/resources/db/migration/V78__v1.8_release.sql +++ b/backend/src/main/resources/db/migration/V78__v1.8_release.sql @@ -52,21 +52,27 @@ create table test_case_review_load ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; -- test_resource_pool add column -ALTER TABLE test_resource_pool ADD heap VARCHAR(200) NULL; -ALTER TABLE test_resource_pool ADD gc_algo VARCHAR(200) NULL; +ALTER TABLE test_resource_pool + ADD heap VARCHAR(200) NULL; +ALTER TABLE test_resource_pool + ADD gc_algo VARCHAR(200) NULL; -- create tale api_document_share -CREATE TABLE IF NOT EXISTS `api_document_share` ( - `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Api Document Share Info ID', - `create_time` BIGINT ( 13 ) NOT NULL COMMENT 'Create timestamp', - `create_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, - `update_time` BIGINT ( 13 ) NOT NULL COMMENT 'last visit timestamp', - `share_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'single or batch', - `share_api_id` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'APiDefinition.id (JSONArray format. Order by TreeSet)', - PRIMARY KEY (`id`) USING BTREE, - INDEX `share_type`(`share_type`) USING BTREE, - INDEX `share_api_id`(`share_api_id`(125)) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; +CREATE TABLE IF NOT EXISTS `api_document_share` +( + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Api Document Share Info ID', + `create_time` BIGINT(13) NOT NULL COMMENT 'Create timestamp', + `create_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `update_time` BIGINT(13) NOT NULL COMMENT 'last visit timestamp', + `share_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'single or batch', + `share_api_id` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'APiDefinition.id (JSONArray format. Order by TreeSet)', + PRIMARY KEY (`id`) USING BTREE, + INDEX `share_type` (`share_type`) USING BTREE, + INDEX `share_api_id` (`share_api_id`(125)) USING BTREE +) ENGINE = InnoDB + CHARACTER SET = utf8mb4 + COLLATE = utf8mb4_general_ci + ROW_FORMAT = Dynamic; -- swagger_url_project alter table swagger_url_project @@ -91,61 +97,70 @@ alter table test_plan_api_scenario change environment_id environment longtext null comment 'Relevance environment'; -- add Original state -alter table api_definition add original_state varchar(64); -alter table api_scenario add original_state varchar(64); -update api_definition set original_state='Underway'; -update api_scenario set original_state='Underway'; +alter table api_definition + add original_state varchar(64); +alter table api_scenario + add original_state varchar(64); +update api_definition +set original_state='Underway'; +update api_scenario +set original_state='Underway'; -- alter test_case_review_scenario -alter table test_case_review_scenario modify environment longtext null; +alter table test_case_review_scenario + modify environment longtext null; -- schedule table add project_id column -alter table schedule add project_id varchar(50) NULL; +alter table schedule + add project_id varchar(50) NULL; -- set values for new colums of exitsting data update schedule sch inner join test_plan testPlan on - testPlan.id = sch.resource_id - set sch.project_id = testPlan.project_id where - sch.resource_id = testPlan.id; + testPlan.id = sch.resource_id +set sch.project_id = testPlan.project_id +where sch.resource_id = testPlan.id; update schedule sch inner join swagger_url_project sup on - sup.id = sch.resource_id - set sch.project_id = sup.project_id where - sch.resource_id = sup.id; + sup.id = sch.resource_id +set sch.project_id = sup.project_id +where sch.resource_id = sup.id; update schedule sch inner join api_scenario apiScene on - apiScene.id = sch.resource_id - set sch.project_id = apiScene.project_id where - sch.resource_id = apiScene.id; + apiScene.id = sch.resource_id +set sch.project_id = apiScene.project_id +where sch.resource_id = apiScene.id; update schedule sch inner join load_test ldt on - ldt.id = sch.resource_id - set sch.project_id = ldt.project_id where - sch.resource_id = ldt.id; + ldt.id = sch.resource_id +set sch.project_id = ldt.project_id +where sch.resource_id = ldt.id; update schedule sch inner join api_test apiTest on - apiTest.id = sch.resource_id - set sch.project_id = apiTest.project_id where - sch.resource_id = apiTest.id; + apiTest.id = sch.resource_id +set sch.project_id = apiTest.project_id +where sch.resource_id = apiTest.id; -- schedule table add name column -alter table schedule add name varchar(100) NULL; +alter table schedule + add name varchar(100) NULL; -- set values for new colums of exitsting data update schedule sch inner join api_scenario apiScene on - apiScene.id = sch.resource_id - set sch.name = apiScene.name; + apiScene.id = sch.resource_id +set sch.name = apiScene.name; update schedule sch inner join test_plan testPlan on - testPlan.id = sch.resource_id - set sch.name = testPlan.name; + testPlan.id = sch.resource_id +set sch.name = testPlan.name; update schedule sch inner join load_test ldt on - ldt.id = sch.resource_id - set sch.name = ldt.name; + ldt.id = sch.resource_id +set sch.name = ldt.name; update schedule sch inner join api_test apiTest on - apiTest.id = sch.resource_id - set sch.name = apiTest.name; + apiTest.id = sch.resource_id +set sch.name = apiTest.name; update schedule sch inner join swagger_url_project sup on - sup.id = sch.resource_id - set sch.name = LEFT(SUBSTRING_INDEX(sup.swagger_url, '/', 3), 100); + sup.id = sch.resource_id +set sch.name = LEFT(SUBSTRING_INDEX(sup.swagger_url, '/', 3), 100); -- delete an unused colum -alter table schedule drop column custom_data; +alter table schedule + drop column custom_data; -- add sort column -alter table load_test_file add sort int default 0; +alter table load_test_file + add sort int default 0; alter table file_metadata add project_id VARCHAR(50) null; @@ -179,15 +194,14 @@ alter table test_plan alter table test_case modify method varchar(15) null comment 'Test case method type'; -- add test_case_test -create table test_case_test +CREATE TABLE IF NOT EXISTS test_case_test ( - id varchar(70) null, - test_case_id varchar(70) null, - test_id varchar(70) null, - test_type varchar(70) null, - constraint test_case_test_pk - primary key (id) + test_case_id varchar(50) null, + test_id varchar(50) null, + test_type varchar(50) null, + UNIQUE KEY test_case_test_unique_key (test_case_id, test_id) ) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4; + DEFAULT CHARSET = utf8mb4 COMMENT ='测试用例和关联用例的关系表'; + alter table test_case modify test_id varchar(2000) null; \ No newline at end of file diff --git a/frontend/src/business/components/api/definition/model/JsonData.js b/frontend/src/business/components/api/definition/model/JsonData.js index e9e4d441db..280ea6e36d 100644 --- a/frontend/src/business/components/api/definition/model/JsonData.js +++ b/frontend/src/business/components/api/definition/model/JsonData.js @@ -73,7 +73,6 @@ export const API_STATUS = [ ] export const TEST = [ {id: 'performance', name: '性能测试'}, - {id: 'api', name: '接口测试'}, {id: 'testcase', name: '测试用例'}, {id: 'automation', name: '场景测试'} ] diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index d54afef3f5..15193b9724 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -377,7 +377,7 @@ export default { desc: '', result: '' }], - selected:[], + selected: [], remark: '', tags: [], demandId: '', @@ -497,6 +497,8 @@ export default { this.$nextTick(() => (this.isStepTableAlive = true)); }, open(testCase) { + console.log("测试用例") + console.log(testCase) this.projectId = getCurrentProjectID(); if (window.history && window.history.pushState) { history.pushState(null, null, document.URL); @@ -580,7 +582,8 @@ export default { } Object.assign(this.form, tmp); this.form.module = testCase.nodeId; - this.form.testId=testCase.testId + this.form.testId=testCase.selected + console.log(this.form.testId) this.getFileMetaData(testCase); }, setTestCaseExtInfo(testCase) { diff --git a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiScenarioList.vue b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiScenarioList.vue index ef59b7e07c..556f0ba211 100644 --- a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiScenarioList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiScenarioList.vue @@ -274,7 +274,7 @@ export default { execute(row) { this.infoDb = false; let param = this.buildExecuteParam(row); - + console.log(param) if (this.planId) { this.$post("/test/plan/scenario/case/run", param, response => { this.runVisible = true; @@ -293,6 +293,7 @@ export default { // param.id = row.id; param.id = getUUID(); param.planScenarioId = row.id; + console.log(row.id) param.projectId = row.projectId; param.planCaseIds = []; param.planCaseIds.push(row.id);