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 66559e4d12..ac7fb043d3 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 @@ -718,7 +718,7 @@ public class TestPlanApiCaseService { } public List getFailureListByIds(Set planApiCaseIds) { - return extTestPlanApiCaseMapper.getFailureListByIds(planApiCaseIds, null); + return buildCases(extTestPlanApiCaseMapper.getFailureListByIds(planApiCaseIds, null)); } public List getNodeByPlanId(List projectIds, String planId, String protocol) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java index 2d3a17a553..1467372df0 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java @@ -994,7 +994,7 @@ public class TestPlanScenarioCaseService { } public List getListByIds(Set ids) { - return extTestPlanScenarioCaseMapper.getFailureListByIds(ids, null); + return this.buildCases(extTestPlanScenarioCaseMapper.getFailureListByIds(ids, null)); } public TestPlanEnvInfoDTO generateEnvironmentInfo(TestPlanReport testPlanReport) { diff --git a/performance-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml b/performance-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml index 9533c76642..b9e1ab90b9 100644 --- a/performance-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml +++ b/performance-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanLoadCaseMapper.xml @@ -295,7 +295,7 @@ select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id, - tplc.create_user, tplc.load_report_id + lt.create_user, tplc.load_report_id from test_plan_load_case tplc inner join load_test lt on tplc.load_case_id = lt.id where tplc.id IN diff --git a/performance-test/backend/src/main/java/io/metersphere/plan/notice/LoadReportStatusEvent.java b/performance-test/backend/src/main/java/io/metersphere/plan/notice/LoadReportStatusEvent.java index 7a3f4d3c3c..16e1a01058 100644 --- a/performance-test/backend/src/main/java/io/metersphere/plan/notice/LoadReportStatusEvent.java +++ b/performance-test/backend/src/main/java/io/metersphere/plan/notice/LoadReportStatusEvent.java @@ -1,24 +1,27 @@ package io.metersphere.plan.notice; import io.metersphere.base.domain.LoadTestReport; -import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper; +import io.metersphere.base.domain.TestPlanLoadCaseExample; +import io.metersphere.base.domain.TestPlanLoadCaseWithBLOBs; +import io.metersphere.base.mapper.TestPlanLoadCaseMapper; import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.constants.TestPlanLoadCaseStatus; +import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import io.metersphere.consumer.LoadTestFinishEvent; +import io.metersphere.plan.service.PerfQueueService; +import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; - @Component @Transactional(rollbackFor = Exception.class) public class LoadReportStatusEvent implements LoadTestFinishEvent { @Resource - private ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper; + private TestPlanLoadCaseMapper testPlanLoadCaseMapper; private void updateLoadCaseStatus(LoadTestReport loadTestReport) { String reportId = loadTestReport.getId(); @@ -32,7 +35,20 @@ public class LoadReportStatusEvent implements LoadTestFinishEvent { result = TestPlanLoadCaseStatus.success.name(); } LogUtil.info("update plan load case status: " + result); - extTestPlanLoadCaseMapper.updateCaseStatus(reportId, result); + // 更新测试计划关联数据状态 + TestPlanLoadCaseExample example = new TestPlanLoadCaseExample(); + example.createCriteria().andIdEqualTo(loadTestReport.getTestId()); + if (testPlanLoadCaseMapper.countByExample(example) > 0) { + TestPlanLoadCaseWithBLOBs loadCase = new TestPlanLoadCaseWithBLOBs(); + loadCase.setId(loadTestReport.getTestId()); + loadCase.setStatus(TestPlanLoadCaseStatus.success.name()); + testPlanLoadCaseMapper.updateByPrimaryKeySelective(loadCase); + LogUtil.info("Execute test_plan_load_case OVER. Now send kafka to Test_Track. key:" + loadCase.getId()); + PerfQueueService perfQueueService = CommonBeanFactory.getBean(PerfQueueService.class); + if (perfQueueService != null) { + perfQueueService.checkTestPlanLoadCaseExecOver(loadCase.getId(), null); + } + } } } 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 3d9df9a48f..9342da2932 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 @@ -1180,6 +1180,21 @@ public class TestPlanReportService { testPlanReportContentMapper.insert(content); } + private Map parseLoadCaseReportMap(String loadReportStructStr) { + Map returnMap = new HashMap<>(); + if (StringUtils.isNotEmpty(loadReportStructStr)) { + Map caseReportList = null; + try { + caseReportList = JSON.parseMap(loadReportStructStr); + } catch (Exception ignored) { + } + if (MapUtils.isNotEmpty(caseReportList)) { + returnMap = caseReportList; + } + } + return returnMap; + } + private Map parseCaseReportMap(String reportStructStr) { Map returnMap = new HashMap<>(); if (StringUtils.isNotEmpty(reportStructStr)) { @@ -1236,7 +1251,7 @@ public class TestPlanReportService { //查找性能测试报告结果 if (DiscoveryUtil.hasService(MicroServiceName.PERFORMANCE_TEST)) { LogUtil.info("测试计划报告【" + testPlanReportContentWithBLOBs.getTestPlanReportId() + "】开始查找性能测试报告结果"); - Map testPlanLoadCaseIdAndReportIdMap = this.parseCaseReportMap(testPlanReportContentWithBLOBs.getPlanLoadCaseReportStruct()); + Map testPlanLoadCaseIdAndReportIdMap = this.parseLoadCaseReportMap(testPlanReportContentWithBLOBs.getPlanLoadCaseReportStruct()); if (MapUtils.isNotEmpty(testPlanLoadCaseIdAndReportIdMap)) { ApiPlanReportRequest request = new ApiPlanReportRequest(); request.setConfig(reportConfig); 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 0dded8a95c..795899076b 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 @@ -890,7 +890,6 @@ public class TestPlanService { LoggerUtil.info("预生成测试计划报告【" + reportInfoDTO.getTestPlanReport() != null ? reportInfoDTO.getTestPlanReport().getName() : StringUtils.EMPTY + "】计划报告ID[" + planReportId + "]"); - List apiTestCases = null; List scenarioCases = null; List uiScenarios = null;