diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index 8ccdc8fb47..c83c9646b1 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -35,6 +35,7 @@ import io.metersphere.plugin.core.MsTestElement; import io.metersphere.service.SystemParameterService; import io.metersphere.service.definition.TcpApiParamService; import io.metersphere.utils.LoggerUtil; +import io.metersphere.vo.BooleanPool; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -127,6 +128,8 @@ public class ApiExecuteService { request.setReportId(request.getTestPlanId()); } LoggerUtil.info("开始执行单条用例【 " + testCaseWithBLOBs.getId() + " 】", request.getReportId()); + RunModeConfigDTO runModeConfigDTO = new RunModeConfigDTO(); + jMeterService.verifyPool(testCaseWithBLOBs.getProjectId(), runModeConfigDTO); // 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取 if (testCaseWithBLOBs != null && StringUtils.isNotEmpty(testCaseWithBLOBs.getRequest())) { @@ -135,11 +138,19 @@ public class ApiExecuteService { if (LoggerUtil.getLogger().isDebugEnabled()) { LoggerUtil.debug("生成jmx文件:" + ElementUtil.hashTreeToString(jmeterHashTree)); } + // 调用执行方法 JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testCaseWithBLOBs.getId(), StringUtils.isEmpty(request.getReportId()) ? request.getId() : request.getReportId(), request.getRunMode(), jmeterHashTree); if (MapUtils.isNotEmpty(extendedParameters)) { runRequest.setExtendedParameters(extendedParameters); } + if (StringUtils.isNotBlank(runModeConfigDTO.getResourcePoolId())) { + runRequest.setPoolId(runModeConfigDTO.getResourcePoolId()); + BooleanPool pool = GenerateHashTreeUtil.isResourcePool(runModeConfigDTO.getResourcePoolId()); + runRequest.setPool(pool); + BaseSystemConfigDTO baseInfo = systemParameterService.getBaseInfo(); + runRequest.setPlatformUrl(GenerateHashTreeUtil.getPlatformUrl(baseInfo, runRequest, null)); + } jMeterService.run(runRequest); } catch (Exception ex) { ApiDefinitionExecResult result = apiDefinitionExecResultMapper.selectByPrimaryKey(request.getReportId()); diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java index 0e823c04e6..8bfb7dd412 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java @@ -745,6 +745,7 @@ public class TestPlanApiCaseService { if (apiCase == null) { MSException.throwException("用例已经被删除"); } + String reportName = apiCase.getName(); ApiDefinitionExecResultWithBLOBs result = ApiDefinitionExecResultUtil.add(testId, ApiReportStatus.RUNNING.name(), reportId, Objects.requireNonNull(SessionUtils.getUser()).getId()); result.setName(reportName); diff --git a/project-management/frontend/src/business/menu/appmanage/AppManage.vue b/project-management/frontend/src/business/menu/appmanage/AppManage.vue index ff6e76f7dc..467fd3e0d7 100644 --- a/project-management/frontend/src/business/menu/appmanage/AppManage.vue +++ b/project-management/frontend/src/business/menu/appmanage/AppManage.vue @@ -425,6 +425,16 @@ export default { getResourcePools() { this.result = getTestResourcePools().then(response => { this.resourcePools = response.data; + let isDelPool = true; + this.resourcePools.forEach(item =>{ + if(item.id === this.config.resourcePoolId){ + isDelPool = false; + } + }) + if(isDelPool){ + this.config.resourcePoolId = undefined; + this.config.poolEnable = false; + } }); }, runModeChange(value, other) { diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index 0f30c15917..73363babb0 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -51,6 +51,7 @@ import io.metersphere.xpack.api.service.ApiPoolDebugService; import io.metersphere.xpack.track.dto.IssuesDao; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -1799,9 +1800,13 @@ public class TestPlanService { for (String id : ids) { TestPlanWithBLOBs testPlan = testPlanMap.get(id); + String planReportId = UUID.randomUUID().toString(); //创建测试报告 RunModeConfigDTO runModeConfigDTO = JSON.parseObject(testPlan.getRunModeConfig(), RunModeConfigDTO.class); + runModeConfigDTO = ObjectUtils.isEmpty(runModeConfigDTO) ? new RunModeConfigDTO() : runModeConfigDTO; + this.verifyPool(testPlan.getProjectId(), runModeConfigDTO); + this.genTestPlanReport(planReportId, testPlan.getId(), request.getUserId(), request.getTriggerMode(), runModeConfigDTO); //测试计划准备执行,取消测试计划的实际结束时间 extTestPlanMapper.updateActualEndTimeIsNullById(testPlan.getId()); diff --git a/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue b/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue index c2d7f13d8b..fd7b5a0200 100644 --- a/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue +++ b/test-track/frontend/src/business/plan/view/comonents/api/TestPlanApiCaseList.vue @@ -515,6 +515,8 @@ export default { .then(() => { this.runningReport.add(reportId); this.$refs.apiCaseResult.open(reportId); + },error =>{ + this.rowLoading = ""; }); }, handleTestEnd(reportId) {