diff --git a/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java b/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java index be5720e5b7..86273196b2 100644 --- a/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java +++ b/performance-test/backend/src/main/java/io/metersphere/plan/service/TestPlanLoadCaseService.java @@ -10,6 +10,7 @@ import io.metersphere.base.mapper.TestPlanLoadCaseMapper; import io.metersphere.base.mapper.ext.ExtLoadTestMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper; +import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.constants.TestPlanLoadCaseStatus; import io.metersphere.commons.utils.*; @@ -26,6 +27,7 @@ import io.metersphere.plan.service.remote.TestPlanService; import io.metersphere.request.*; import io.metersphere.service.*; import io.metersphere.xpack.resourcepool.service.ValidQuotaResourcePoolService; +import jakarta.annotation.Resource; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; @@ -34,9 +36,7 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.PathVariable; -import jakarta.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -378,6 +378,8 @@ public class TestPlanLoadCaseService { } if (StringUtils.isEmpty(status)) { status = Translator.get("not_execute"); + } else if (StringUtils.equals(PerformanceTestStatus.Completed.name(), status)) { + status = TestPlanLoadCaseStatus.success.name(); } loadCaseDTO.setReportId(reportID); loadCaseDTO.setLoadReportId(reportID); 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 795899076b..28539a4268 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 @@ -1370,8 +1370,7 @@ public class TestPlanService { TestPlanCaseReportResultDTO testPlanExecuteReportDTO = testPlanReportService.selectCaseDetailByTestPlanReport(config, testPlan.getId(), testPlanReportContentWithBLOBs); report = generateTestPlanReport( config, - testPlanReport.getCreator(), - StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), TestPlanReportStatus.COMPLETED.name(), TestPlanReportStatus.SUCCESS.name(), TestPlanReportStatus.FAILED.name()), + testPlanReport, testPlan, testPlanExecuteReportDTO); } returnDTO.setTestPlanSimpleReportDTO(report); @@ -1488,17 +1487,20 @@ public class TestPlanService { } //根据用例运行结果生成测试计划报告 - public TestPlanSimpleReportDTO generateTestPlanReport(Map reportConfig, String operator, boolean isTestPlanReportExecuteOver, TestPlanWithBLOBs testPlan, TestPlanCaseReportResultDTO testPlanCaseReportResultDTO) { + public TestPlanSimpleReportDTO generateTestPlanReport(Map reportConfig, TestPlanReport testPlanReport, TestPlanWithBLOBs testPlan, TestPlanCaseReportResultDTO testPlanCaseReportResultDTO) { TestPlanSimpleReportDTO report = new TestPlanSimpleReportDTO(); - if (ObjectUtils.anyNotNull(testPlan, testPlanCaseReportResultDTO)) { + if (ObjectUtils.anyNotNull(testPlan, testPlanReport, testPlanCaseReportResultDTO)) { TestPlanFunctionResultReportDTO functionResult = new TestPlanFunctionResultReportDTO(); TestPlanApiResultReportDTO apiResult = new TestPlanApiResultReportDTO(); TestPlanUiResultReportDTO uiResult = new TestPlanUiResultReportDTO(); report.setFunctionResult(functionResult); report.setApiResult(apiResult); report.setUiResult(uiResult); - report.setStartTime(testPlan.getActualStartTime()); - report.setEndTime(testPlan.getActualEndTime()); + report.setStartTime(testPlanReport.getCreateTime()); + if (testPlanReport.getCreateTime() != testPlanReport.getEndTime() && testPlanReport.getEndTime() != 0) { + //防止测试计划报告非正常状态停止时造成的测试时间显示不对 + report.setEndTime(testPlanReport.getEndTime()); + } report.setSummary(testPlan.getReportSummary()); report.setConfig(testPlan.getReportConfig()); @@ -1517,7 +1519,11 @@ public class TestPlanService { } //功能用例的状态更新以及统计 - testPlanTestCaseService.calculateReportByTestCaseList(operator, testPlan, isTestPlanReportExecuteOver, testPlanCaseReportResultDTO.getFunctionCaseList(), report); + testPlanTestCaseService.calculateReportByTestCaseList( + testPlanReport.getCreator(), + testPlan, + StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), TestPlanReportStatus.COMPLETED.name(), TestPlanReportStatus.SUCCESS.name(), TestPlanReportStatus.FAILED.name()), + testPlanCaseReportResultDTO.getFunctionCaseList(), report); if (report.getFunctionAllCases() == null || report.getIssueList() == null) { //构建功能用例和issue this.buildFunctionalReport(report, reportConfig, testPlan.getId()); 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 d540593b61..42b08fcad9 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 @@ -60,15 +60,6 @@ public class PlanTestPlanLoadCaseService extends LoadTestService { } } - public void calculatePlanReport(List reportIds, TestPlanSimpleReportDTO report) { - try { - List planReportCaseDTOs = planLoadTestReportService.getPlanReportCaseDTO(reportIds); - calculatePlanReport(report, planReportCaseDTOs); - } catch (MSException e) { - LogUtil.error(e); - } - } - private void calculatePlanReport(TestPlanSimpleReportDTO report, List planReportCaseDTOS) { TestPlanLoadResultReportDTO loadResult = new TestPlanLoadResultReportDTO(); report.setLoadResult(loadResult);