diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 17ab8b2cac..54ac08e65a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -121,6 +121,14 @@ public class MsScenario extends MsTestElement { variables.stream().filter(ScenarioVariable::isConstantValid).forEach(keyValue -> arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") ); + + List variableList = variables.stream().filter(ScenarioVariable::isListValid).collect(Collectors.toList()); + variableList.forEach(item -> { + String[] arrays = item.getValue().split(","); + for (int i = 0; i < arrays.length; i++) { + arguments.addArgument(item.getName() + "_" + (i + 1), arrays[i], "="); + } + }); } if (config != null && config.getConfig() != null && config.getConfig().getCommonConfig() != null && CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/variable/ScenarioVariable.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/variable/ScenarioVariable.java index b255aa8457..417711dfa2 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/variable/ScenarioVariable.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/variable/ScenarioVariable.java @@ -41,8 +41,7 @@ public class ScenarioVariable { private String maxNumber; public boolean isConstantValid() { - if ((StringUtils.equals(this.type, VariableTypeConstants.CONSTANT.name()) - || StringUtils.equals(this.type, VariableTypeConstants.LIST.name())) && StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value)) { + if (StringUtils.equals(this.type, VariableTypeConstants.CONSTANT.name()) && StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value)) { return true; } return false; @@ -55,6 +54,13 @@ public class ScenarioVariable { return false; } + public boolean isListValid() { + if (StringUtils.equals(this.type, VariableTypeConstants.LIST.name()) && StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(value) && value.indexOf(",") != -1) { + return true; + } + return false; + } + public boolean isCounterValid() { if (StringUtils.equals(this.type, VariableTypeConstants.COUNTER.name()) && StringUtils.isNotEmpty(name)) { return true; diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.java index fad4c49e32..2cb340e72f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.java @@ -11,4 +11,5 @@ public interface ExtTestPlanLoadCaseMapper { List selectIdsNotInPlan(@Param("projectId") String projectId, @Param("planId") String planId); List selectTestPlanLoadCaseList(@Param("request") LoadCaseRequest request); void updateCaseStatus(@Param("reportId") String reportId, @Param("status") String status); + List getStatusByTestPlanId(@Param("planId") String planId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml index c26e9fc31f..d46688f5e1 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml @@ -62,4 +62,7 @@ + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 69fe39c2c7..124dfccddd 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -19,10 +19,7 @@ import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; -import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; -import io.metersphere.base.mapper.ext.ExtTestCaseMapper; -import io.metersphere.base.mapper.ext.ExtTestPlanMapper; -import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; +import io.metersphere.base.mapper.ext.*; import io.metersphere.commons.constants.*; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; @@ -103,6 +100,10 @@ public class TestPlanService { private JMeterService jMeterService; @Resource private ApiAutomationService apiAutomationService; + @Resource + private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper; + @Resource + private ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper; public synchronized void addTestPlan(AddTestPlanRequest testPlan) { if (getTestPlanByName(testPlan.getName()).size() > 0) { @@ -550,18 +551,10 @@ public class TestPlanService { } public void editTestPlanStatus(String planId) { - List statusList = extTestPlanTestCaseMapper.getStatusByPlanId(planId); TestPlan testPlan = new TestPlan(); testPlan.setId(planId); - for (String status : statusList) { - if (StringUtils.equals(status, TestPlanTestCaseStatus.Prepare.name()) - || StringUtils.equals(status, TestPlanTestCaseStatus.Underway.name())) { - testPlan.setStatus(TestPlanStatus.Underway.name()); - testPlanMapper.updateByPrimaryKeySelective(testPlan); - return; - } - } - testPlan.setStatus(TestPlanStatus.Completed.name()); + String status = calcTestPlanStatus(planId); + testPlan.setStatus(status); testPlanMapper.updateByPrimaryKeySelective(testPlan); TestPlan testPlans = getTestPlan(planId); List userIds = new ArrayList<>(); @@ -590,6 +583,36 @@ public class TestPlanService { } + + private String calcTestPlanStatus(String planId) { + // test-plan-functional-case status + List funcStatusList = extTestPlanTestCaseMapper.getStatusByPlanId(planId); + for (String funcStatus : funcStatusList) { + if (StringUtils.equals(funcStatus, TestPlanTestCaseStatus.Prepare.name()) + || StringUtils.equals(funcStatus, TestPlanTestCaseStatus.Underway.name())) { + return TestPlanStatus.Underway.name(); + } + } + + // test-plan-api-case status + List apiStatusList = extTestPlanApiCaseMapper.getStatusByTestPlanId(planId); + for (String apiStatus : apiStatusList) { + if (apiStatus == null) { + return TestPlanStatus.Underway.name(); + } + } + + // test-plan-load-case status + List loadStatusList = extTestPlanLoadCaseMapper.getStatusByTestPlanId(planId); + for (String loadStatus : loadStatusList) { + if (loadStatus == null) { + return TestPlanStatus.Underway.name(); + } + } + + return TestPlanStatus.Completed.name(); + } + public String getProjectNameByPlanId(String testPlanId) { List projectIds = testPlanProjectService.getProjectIdsByPlanId(testPlanId); ProjectExample projectExample = new ProjectExample(); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 521a3fc36c..827288a95e 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -143,7 +143,7 @@ highlight-current @node-expand="nodeExpand" @node-collapse="nodeCollapse" - :allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable> + :allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable class="ms-is-leaf"> >> .is-leaf { color: transparent; } diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index bccb5c6766..254c664be6 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -1,96 +1,97 @@ diff --git a/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue b/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue index c8b706842e..4665c8e08f 100644 --- a/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue +++ b/frontend/src/business/components/api/automation/scenario/variable/VariableList.vue @@ -107,6 +107,9 @@ }, addParameters(v) { v.id = getUUID(); + if (v.type === 'CSV') { + v.delimiter = ","; + } this.variables.push(v); let index = 1; this.variables.forEach(item => { diff --git a/frontend/src/business/components/api/definition/components/response/RequestMetric.vue b/frontend/src/business/components/api/definition/components/response/RequestMetric.vue index 3d7f5af105..660da3ecae 100644 --- a/frontend/src/business/components/api/definition/components/response/RequestMetric.vue +++ b/frontend/src/business/components/api/definition/components/response/RequestMetric.vue @@ -1,10 +1,6 @@ @@ -264,17 +267,22 @@ export default { title: loadCase.caseName, message: this.$t('test_track.plan.load_case.exec').toString() }); - this.initTable(); + this.updateStatus(loadCase, 'run'); }).catch(() => { - this.$post('/test/plan/load/case/update', {id: loadCase.id, status: "error"}, () => { - this.initTable(); - }); + this.updateStatus(loadCase, 'error'); this.$notify.error({ title: loadCase.caseName, message: this.$t('test_track.plan.load_case.error').toString() }); }) }, + updateStatus(loadCase, status) { + this.$post('/test/plan/load/case/update', {id: loadCase.id, status: status}, () => { + this.$post('/test/plan/edit/status/' + loadCase.testPlanId, {},() => { + this.initTable(); + }); + }); + }, handleDelete(loadCase) { this.result = this.$get('/test/plan/load/case/delete/' + loadCase.id, () => { this.$success(this.$t('test_track.cancel_relevance_success'));