diff --git a/backend/src/main/java/io/metersphere/api/exec/api/TestPlanApiExecuteService.java b/backend/src/main/java/io/metersphere/api/exec/api/TestPlanApiExecuteService.java index 6ba14b32a6..c037e96286 100644 --- a/backend/src/main/java/io/metersphere/api/exec/api/TestPlanApiExecuteService.java +++ b/backend/src/main/java/io/metersphere/api/exec/api/TestPlanApiExecuteService.java @@ -15,6 +15,7 @@ import io.metersphere.base.mapper.ApiDefinitionExecResultMapper; import io.metersphere.base.mapper.TestPlanApiCaseMapper; import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.ApiRunMode; +import io.metersphere.commons.constants.TriggerMode; import io.metersphere.constants.RunModeConstants; import io.metersphere.dto.JmeterRunRequestDTO; import io.metersphere.dto.MsExecResponseDTO; @@ -54,6 +55,7 @@ public class TestPlanApiExecuteService { if (CollectionUtils.isEmpty(ids)) { return new LinkedList<>(); } + LoggerUtil.debug("开始查询测试计划用例"); TestPlanApiCaseExample example = new TestPlanApiCaseExample(); example.createCriteria().andIdIn(ids); example.setOrderByClause("`order` DESC"); @@ -80,9 +82,11 @@ public class TestPlanApiExecuteService { SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); } + LoggerUtil.debug("开始生成测试计划队列"); String reportType = request.getConfig() != null ? request.getConfig().getReportType() : null; String poolId = request.getConfig() != null ? request.getConfig().getResourcePoolId() : null; - DBTestQueue deQueue = apiExecutionQueueService.add(executeQueue, poolId, ApiRunMode.API_PLAN.name(), request.getPlanReportId(), reportType, request.getTriggerMode()); + String runMode = StringUtils.equals(request.getTriggerMode(), TriggerMode.MANUAL.name()) ? ApiRunMode.API_PLAN.name() : ApiRunMode.SCHEDULE_API_PLAN.name(); + DBTestQueue deQueue = apiExecutionQueueService.add(executeQueue, poolId, ApiRunMode.API_PLAN.name(), request.getPlanReportId(), reportType, runMode); //如果是测试计划生成报告的执行,则更新执行信息、执行线程信息。 if (TestPlanReportExecuteCatch.containsReport(request.getPlanReportId())) { @@ -92,12 +96,12 @@ public class TestPlanApiExecuteService { } // 开始选择执行模式 if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) { - // 开始串行执行 + LoggerUtil.debug("开始串行执行"); if (deQueue != null && deQueue.getQueue() != null) { apiScenarioSerialService.serial(deQueue, deQueue.getQueue()); } } else { - // 开始并发执行 + LoggerUtil.debug("开始并发执行"); if (deQueue != null && deQueue.getQueue() != null) { parallel(executeQueue, request, deQueue); } @@ -119,7 +123,8 @@ public class TestPlanApiExecuteService { if (request.getConfig() == null || !GenerateHashTreeUtil.isResourcePool(request.getConfig().getResourcePoolId()).isPool()) { hashTree = apiScenarioSerialService.generateHashTree(testPlanApiCase.getId()); } - JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testPlanApiCase.getId(), reportId, request.getTriggerMode(), hashTree); + String runMode = StringUtils.equals(request.getTriggerMode(), TriggerMode.MANUAL.name()) ? ApiRunMode.API_PLAN.name() : ApiRunMode.SCHEDULE_API_PLAN.name(); + JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testPlanApiCase.getId(), reportId, runMode, hashTree); if (request.getConfig() != null) { runRequest.setPool(GenerateHashTreeUtil.isResourcePool(request.getConfig().getResourcePoolId())); runRequest.setPoolId(request.getConfig().getResourcePoolId()); diff --git a/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java b/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java index dd91cc2794..d0a04d0e3d 100644 --- a/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java +++ b/backend/src/main/java/io/metersphere/api/exec/utils/ApiDefinitionExecResultUtil.java @@ -46,13 +46,7 @@ public class ApiDefinitionExecResultUtil { if (caseWithBLOBs != null) { apiResult.setName(caseWithBLOBs.getName()); } - if (StringUtils.equalsIgnoreCase(request.getTriggerMode(), ApiRunMode.SCHEDULE_API_PLAN.name())) { - apiResult.setTriggerMode(TriggerMode.SCHEDULE.name()); - } else if (StringUtils.equalsIgnoreCase(request.getTriggerMode(), ApiRunMode.JENKINS_API_PLAN.name())) { - apiResult.setTriggerMode(TriggerMode.MANUAL.name()); - } else { - apiResult.setTriggerMode(TriggerMode.BATCH.name()); - } + apiResult.setTriggerMode(request.getTriggerMode()); apiResult.setActuator("LOCAL"); if (request.getConfig() != null && GenerateHashTreeUtil.isResourcePool(request.getConfig().getResourcePoolId()).isPool()) { apiResult.setActuator(request.getConfig().getResourcePoolId()); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 2f1fe350b0..0847ad6ddb 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -325,9 +325,6 @@ public class ApiDefinitionExecResultService { saveResult.setId(reportId); saveResult.setActuator("LOCAL"); saveResult.setName(item.getName()); - if (StringUtils.equals(type, TriggerMode.SCHEDULE.name())) { - saveResult.setTriggerMode(TriggerMode.SCHEDULE.name()); - } saveResult.setType(type); saveResult.setCreateTime(item.getStartTime()); if (SessionUtils.getUser() != null) { 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 22f654d33a..7499baea2a 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1152,13 +1152,7 @@ public class TestPlanService { private void executeApiTestCase(String triggerMode, String planReportId, String userId, List planCaseIds, RunModeConfigDTO runModeConfig) { BatchRunDefinitionRequest request = new BatchRunDefinitionRequest(); - if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) { - request.setTriggerMode(ApiRunMode.JENKINS_API_PLAN.name()); - } else if (StringUtils.equals(triggerMode, ReportTriggerMode.MANUAL.name())) { - request.setTriggerMode(ApiRunMode.MANUAL_PLAN.name()); - } else { - request.setTriggerMode(ApiRunMode.SCHEDULE_API_PLAN.name()); - } + request.setTriggerMode(triggerMode); request.setPlanIds(planCaseIds); request.setPlanReportId(planReportId); request.setConfig(runModeConfig); @@ -1912,7 +1906,6 @@ public class TestPlanService { } public String runPlan(TestplanRunRequest testplanRunRequest) { - String envType = testplanRunRequest.getEnvironmentType(); Map envMap = testplanRunRequest.getEnvMap(); String environmentGroupId = testplanRunRequest.getEnvironmentGroupId(); diff --git a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue index 76c325952a..d860e40bc0 100644 --- a/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/api/TestPlanApiCaseList.vue @@ -575,7 +575,7 @@ export default { }); }, handleRunBatch(config) { - let obj = {planIds: this.testPlanCaseIds, config: config}; + let obj = {planIds: this.testPlanCaseIds, config: config, triggerMode:"BATCH"}; this.$post("/test/plan/api/case/run", obj, response => { this.$message(this.$t('commons.run_message')); this.$refs.taskCenter.open();