diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 5f4f64e300..67c2e5da0f 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -30,6 +30,7 @@ import io.metersphere.utils.DiscoveryUtil; import io.metersphere.xpack.track.dto.IssuesDao; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -256,58 +257,45 @@ public class TestPlanReportService { Set serviceIdSet = DiscoveryUtil.getServiceIdSet(); - try { - if (serviceIdSet.contains(MicroServiceName.API_TEST)) { - // todo 远程调用失败处理逻辑 - TestPlanApiReportInfoDTO testPlanApiReportInfoDTO = planTestPlanScenarioCaseService.genApiReportInfoForSchedule(planId, runModeConfigDTO); - Map planScenarioIdMap = testPlanApiReportInfoDTO.getPlanScenarioIdMap(); - Map planApiCaseIdMap = testPlanApiReportInfoDTO.getPlanApiCaseIdMap(); - runInfoDTO = testPlanApiReportInfoDTO.getRunInfoDTO(); + if (serviceIdSet.contains(MicroServiceName.API_TEST)) { + TestPlanApiReportInfoDTO testPlanApiReportInfoDTO = planTestPlanScenarioCaseService.genApiReportInfoForSchedule(planId, runModeConfigDTO); + Map planScenarioIdMap = testPlanApiReportInfoDTO.getPlanScenarioIdMap(); + Map planApiCaseIdMap = testPlanApiReportInfoDTO.getPlanApiCaseIdMap(); + runInfoDTO = testPlanApiReportInfoDTO.getRunInfoDTO(); - saveRequest.setApiCaseIsExecuting(!planApiCaseIdMap.isEmpty()); - saveRequest.setScenarioIsExecuting(!planScenarioIdMap.isEmpty()); - saveRequest.setApiCaseIdMap(planApiCaseIdMap); - saveRequest.setScenarioIdMap(planScenarioIdMap); + saveRequest.setApiCaseIsExecuting(!planApiCaseIdMap.isEmpty()); + saveRequest.setScenarioIsExecuting(!planScenarioIdMap.isEmpty()); + saveRequest.setApiCaseIdMap(planApiCaseIdMap); + saveRequest.setScenarioIdMap(planScenarioIdMap); - returnDTO.setPlanScenarioIdMap(planScenarioIdMap); - returnDTO.setApiTestCaseDataMap(planApiCaseIdMap); - } - } catch (Exception e) { - LogUtil.error(e); + returnDTO.setPlanScenarioIdMap(planScenarioIdMap); + returnDTO.setApiTestCaseDataMap(planApiCaseIdMap); } - try { - if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) { - // todo 远程调用失败处理逻辑 - Map performanceIdMap = new LinkedHashMap<>(); - List testPlanLoadCaseDTOList = planTestPlanLoadCaseService.list(planId); - for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) { - performanceIdMap.put(dto.getId(), dto.getLoadCaseId()); - } - saveRequest.setPerformanceIsExecuting(!performanceIdMap.isEmpty()); - saveRequest.setPerformanceIdMap(performanceIdMap); - returnDTO.setPerformanceIdMap(performanceIdMap); + if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) { + Map performanceIdMap = new LinkedHashMap<>(); + List testPlanLoadCaseDTOList = planTestPlanLoadCaseService.list(planId); + for (TestPlanLoadCaseDTO dto : testPlanLoadCaseDTOList) { + performanceIdMap.put(dto.getId(), dto.getLoadCaseId()); } - } catch (Exception e) { - LogUtil.error(e); + saveRequest.setPerformanceIsExecuting(!performanceIdMap.isEmpty()); + saveRequest.setPerformanceIdMap(performanceIdMap); + + returnDTO.setPerformanceIdMap(performanceIdMap); } - try { - if (serviceIdSet.contains(MicroServiceName.UI_TEST)) { - // todo 远程调用失败处理逻辑 - Map uiScenarioIdMap = new LinkedHashMap<>(); - List testPlanUiScenarioList = planTestPlanUiScenarioCaseService.list(planId); - for (TestPlanUiScenario dto : testPlanUiScenarioList) { - uiScenarioIdMap.put(dto.getId(), dto.getUiScenarioId()); - } - saveRequest.setUiScenarioIsExecuting(!uiScenarioIdMap.isEmpty()); - saveRequest.setUiScenarioIdMap(uiScenarioIdMap); - returnDTO.setUiScenarioIdMap(uiScenarioIdMap); + if (serviceIdSet.contains(MicroServiceName.UI_TEST)) { + Map uiScenarioIdMap = new LinkedHashMap<>(); + List testPlanUiScenarioList = planTestPlanUiScenarioCaseService.list(planId); + for (TestPlanUiScenario dto : testPlanUiScenarioList) { + uiScenarioIdMap.put(dto.getId(), dto.getUiScenarioId()); } - } catch (Exception e) { - LogUtil.error(e); + saveRequest.setUiScenarioIsExecuting(!uiScenarioIdMap.isEmpty()); + saveRequest.setUiScenarioIdMap(uiScenarioIdMap); + + returnDTO.setUiScenarioIdMap(uiScenarioIdMap); } @@ -385,10 +373,10 @@ public class TestPlanReportService { testPlanReport.setIsUiScenarioExecuting(saveRequest.isUiScenarioIsExecuting()); } - if (testPlanReport.getIsScenarioExecuting() - || testPlanReport.getIsApiCaseExecuting() - || testPlanReport.getIsPerformanceExecuting() - || testPlanReport.getIsUiScenarioExecuting()) { + if (BooleanUtils.isTrue(testPlanReport.getIsScenarioExecuting()) + || BooleanUtils.isTrue(testPlanReport.getIsApiCaseExecuting()) + || BooleanUtils.isTrue(testPlanReport.getIsPerformanceExecuting()) + || BooleanUtils.isTrue(testPlanReport.getIsUiScenarioExecuting())) { testPlanReport.setStatus(TestPlanReportStatus.RUNNING.name()); } else { testPlanReport.setStatus(TestPlanReportStatus.COMPLETED.name()); @@ -1086,9 +1074,10 @@ public class TestPlanReportService { private void generateEnvironmentInfo(TestPlanSimpleReportDTO testPlanReportDTO, String reportId) { TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId); try { - // todo 调用失败处理 - TestPlanEnvInfoDTO testPlanEnvInfo = planTestPlanScenarioCaseService.generateEnvironmentInfo(testPlanReport); - BeanUtils.copyBean(testPlanReportDTO, testPlanEnvInfo); + if (DiscoveryUtil.hasService(MicroServiceName.API_TEST)) { + TestPlanEnvInfoDTO testPlanEnvInfo = planTestPlanScenarioCaseService.generateEnvironmentInfo(testPlanReport); + BeanUtils.copyBean(testPlanReportDTO, testPlanEnvInfo); + } } catch (Exception e) { LogUtil.error(e); } 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 a6e3a49990..4c8aaf29ae 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 @@ -1157,12 +1157,9 @@ public class TestPlanService { request.setPlanId(planId); request.setSaveResponse(saveResponse); request.setTestPlanExecuteReportDTO(testPlanExecuteReportDTO); - try { - // todo 调用失败处理 + if (DiscoveryUtil.hasService(MicroServiceName.UI_TEST)) { UiPlanReportDTO uiReport = planTestPlanUiScenarioCaseService.getUiReport(request); BeanUtils.copyBean(report, uiReport); - } catch (MSException e) { - LogUtil.error(e); } } @@ -1221,12 +1218,9 @@ public class TestPlanService { ApiPlanReportRequest request = new ApiPlanReportRequest(); request.setConfig(config); request.setTestPlanExecuteReportDTO(testPlanExecuteReportDTO); - try { - // todo 调用失败处理 + if (DiscoveryUtil.hasService(MicroServiceName.API_TEST)) { ApiPlanReportDTO apiPlanReport = planTestPlanScenarioCaseService.getApiExecuteReport(request); BeanUtils.copyBean(report, apiPlanReport); - } catch (Exception e) { - LogUtil.error(e); } } @@ -1239,12 +1233,9 @@ public class TestPlanService { request.setConfig(config); request.setSaveResponse(saveResponse); request.setReportIdMap(loadCaseReportMap); - try { - // todo 调用失败处理 + if (DiscoveryUtil.hasService(MicroServiceName.PERFORMANCE_TEST)) { LoadPlanReportDTO loadPlanReport = planTestPlanLoadCaseService.getLoadExecuteReport(request); BeanUtils.copyBean(report, loadPlanReport); - } catch (Exception e) { - LogUtil.error(e); } } @@ -1352,11 +1343,8 @@ public class TestPlanService { public void runReportWithExceptionHandle(TestPlanSimpleReportDTO report, Function getCaseFunc, BiConsumer setReportCaseFunc) { - try { - // todo 服务调用失败 + if (DiscoveryUtil.hasService(MicroServiceName.UI_TEST)) { setReportCaseFunc.accept(report, getCaseFunc.apply(report)); - } catch (Exception e) { - LogUtil.error(e); } } @@ -1561,12 +1549,9 @@ public class TestPlanService { } public void setPlanCaseEnv(String planId, RunModeConfigDTO runModeConfig) { - try { - // todo 调用失败 + if (DiscoveryUtil.hasService(MicroServiceName.API_TEST)) { planTestPlanApiCaseService.setApiCaseEnv(planId, runModeConfig); planTestPlanScenarioCaseService.setScenarioEnv(planId, runModeConfig); - } catch (Exception e) { - LogUtil.error(e); } } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java index 7e7c5c0d08..6e0412dd8e 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanApiCaseService.java @@ -1,5 +1,6 @@ package io.metersphere.plan.service.remote.api; +import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.*; @@ -7,6 +8,7 @@ import io.metersphere.plan.dto.*; import io.metersphere.plan.request.api.ApiTestCaseRequest; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.utils.TestPlanStatusCalculator; +import io.metersphere.utils.DiscoveryUtil; import org.apache.commons.collections.CollectionUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -36,15 +38,13 @@ public class PlanTestPlanApiCaseService extends ApiTestService { * @return 接口用例的最新执行报告 */ public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) { - try { + if (DiscoveryUtil.hasService(MicroServiceName.API_TEST)) { List planReportCaseDTOS = selectStatusForPlanReport(planId); //计算测试计划中接口用例的相关数据 calculatePlanReport(report, planReportCaseDTOS); //记录接口用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); report.setProjectEnvMap(getPlanProjectEnvMap(idList)); - } catch (MSException e) { - LogUtil.error(e); } } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java index 200ba361c4..f1f407fe3c 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/api/PlanTestPlanScenarioCaseService.java @@ -1,6 +1,7 @@ package io.metersphere.plan.service.remote.api; import io.metersphere.base.domain.TestPlanReport; +import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.*; @@ -10,6 +11,7 @@ import io.metersphere.plan.request.api.ApiPlanReportRequest; import io.metersphere.plan.request.api.ApiScenarioRequest; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.utils.TestPlanStatusCalculator; +import io.metersphere.utils.DiscoveryUtil; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -31,14 +33,12 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService { PlanApiScenarioReportService planApiScenarioReportService; public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) { - try { + if (DiscoveryUtil.hasService(MicroServiceName.API_TEST)) { List planReportCaseDTOS = selectStatusForPlanReport(planId); calculatePlanReport(report, planReportCaseDTOS); //记录接口用例的运行环境信息 List idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList()); report.setProjectEnvMap(getPlanProjectEnvMap(idList)); - } catch (MSException e) { - LogUtil.error(e); } } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java index 41103e8902..0311a964b4 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/performance/PlanTestPlanLoadCaseService.java @@ -1,5 +1,6 @@ package io.metersphere.plan.service.remote.performance; +import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.constants.TestPlanLoadCaseStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; @@ -13,6 +14,7 @@ import io.metersphere.plan.request.performance.LoadCaseRequest; import io.metersphere.plan.request.performance.LoadPlanReportDTO; import io.metersphere.plan.service.TestPlanService; import io.metersphere.plan.utils.TestPlanStatusCalculator; +import io.metersphere.utils.DiscoveryUtil; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -34,11 +36,9 @@ public class PlanTestPlanLoadCaseService extends LoadTestService { private TestPlanService testPlanService; public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) { - try { + if (DiscoveryUtil.hasService(MicroServiceName.PERFORMANCE_TEST)) { List planReportCaseDTOS = selectStatusForPlanReport(planId); calculatePlanReport(report, planReportCaseDTOS); - } catch (MSException e) { - LogUtil.error(e); } } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java index ff1074e628..5c539bd15f 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java @@ -1,6 +1,7 @@ package io.metersphere.plan.service.remote.ui; import io.metersphere.base.domain.TestPlanUiScenario; +import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.*; @@ -16,6 +17,7 @@ import io.metersphere.plan.service.remote.api.PlanTestPlanScenarioCaseService; import io.metersphere.plan.service.remote.api.PlanUiScenarioReportService; import io.metersphere.plan.utils.TestPlanStatusCalculator; import io.metersphere.request.ResetOrderRequest; +import io.metersphere.utils.DiscoveryUtil; import org.jetbrains.annotations.NotNull; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -60,15 +62,12 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService { } public void calculatePlanReport(String planId, TestPlanSimpleReportDTO report) { - try { + if (DiscoveryUtil.hasService(MicroServiceName.UI_TEST)) { List planReportCaseDTOS = selectStatusForPlanReport(planId); TestPlanUiResultReportDTO uiResult = getUiResult(report, planReportCaseDTOS); report.setUiResult(uiResult); - - } catch (MSException e) { - LogUtil.error(e); } }