diff --git a/backend/src/main/java/io/metersphere/commons/constants/TestPlanLoadCaseStatus.java b/backend/src/main/java/io/metersphere/commons/constants/TestPlanLoadCaseStatus.java new file mode 100644 index 0000000000..f2fd163d46 --- /dev/null +++ b/backend/src/main/java/io/metersphere/commons/constants/TestPlanLoadCaseStatus.java @@ -0,0 +1,5 @@ +package io.metersphere.commons.constants; + +public enum TestPlanLoadCaseStatus { + run, error, success +} diff --git a/backend/src/main/java/io/metersphere/track/service/LoadReportStatusEvent.java b/backend/src/main/java/io/metersphere/track/service/LoadReportStatusEvent.java index b6e2667afa..e2ba414a59 100644 --- a/backend/src/main/java/io/metersphere/track/service/LoadReportStatusEvent.java +++ b/backend/src/main/java/io/metersphere/track/service/LoadReportStatusEvent.java @@ -4,6 +4,7 @@ import io.metersphere.base.domain.LoadTestReport; 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.consumer.LoadTestFinishEvent; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; @@ -24,10 +25,10 @@ public class LoadReportStatusEvent implements LoadTestFinishEvent { if (StringUtils.isNotBlank(reportId)) { String result = ""; if (StringUtils.equals(PerformanceTestStatus.Error.name(), status)) { - result = "error"; + result = TestPlanLoadCaseStatus.error.name(); } if (StringUtils.equals(PerformanceTestStatus.Completed.name(), status)) { - result = "success"; + result = TestPlanLoadCaseStatus.success.name(); } extTestPlanLoadCaseMapper.updateCaseStatus(reportId, result); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index b51a6a743e..ac9e4342eb 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -898,7 +898,7 @@ public class TestPlanReportService { if (errorDataCheckMap.get(loadTestReportId) > 10) { performaneReportIDList.remove(loadTestReportId); if (performaneReportIDMap.containsKey(loadTestReportId)) { - finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanApiExecuteStatus.FAILD.name()); + finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanLoadCaseStatus.error.name()); caseReportMap.put(performaneReportIDMap.get(loadTestReportId), loadTestReportId); } } else { @@ -911,14 +911,14 @@ public class TestPlanReportService { testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] SELECT performance ID:" + loadTestReportId + ",RESULT :" + loadTestReportFromDatabase.getStatus()); if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(), PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) { - finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanApiExecuteStatus.SUCCESS.name()); + finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanLoadCaseStatus.success.name()); caseReportMap.put(performaneReportIDMap.get(loadTestReportId), loadTestReportId); performaneReportIDList.remove(loadTestReportId); } } } catch (Exception e) { performaneReportIDList.remove(loadTestReportId); - finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanApiExecuteStatus.FAILD.name()); + finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanLoadCaseStatus.error.name()); caseReportMap.put(performaneReportIDMap.get(loadTestReportId), loadTestReportId); testPlanLog.error(e.getMessage()); } 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 37bd04d9c4..7f19331567 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1172,19 +1172,19 @@ public class TestPlanService { reportId = performanceTestService.run(performanceRequest); if (reportId != null) { performaneReportIDMap.put(reportId, id); - TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs(); - testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId()); - testPlanLoadCase.setLoadReportId(reportId); - testPlanLoadCaseService.update(testPlanLoadCase); - //更新关联处的报告 TestPlanLoadCaseWithBLOBs loadCase = new TestPlanLoadCaseDTO(); loadCase.setId(id); loadCase.setLoadReportId(reportId); - loadCase.setStatus("run"); + loadCase.setStatus(TestPlanLoadCaseStatus.run.name()); testPlanLoadCaseService.update(loadCase); } } catch (Exception e) { + TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs(); + testPlanLoadCase.setId(id); + testPlanLoadCase.setLoadReportId(reportId); + testPlanLoadCase.setStatus(TestPlanLoadCaseStatus.error.name()); + testPlanLoadCaseService.update(testPlanLoadCase); LogUtil.error(e); } performaneThreadIDMap.put(performanceRequest.getTestPlanLoadId(), reportId);