From 28413355765130d3598ba68fdf99934ec1a12261 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 15 Dec 2021 14:25:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=A4=B1=E8=B4=A5=E6=97=B6=E7=8A=B6=E6=80=81=E6=9C=AA?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008758 --user=lyh 【测试跟踪】手动执行测试计划,性能测试没有执行 https://www.tapd.cn/55049933/s/1081054 --- .../commons/constants/TestPlanLoadCaseStatus.java | 5 +++++ .../track/service/LoadReportStatusEvent.java | 5 +++-- .../track/service/TestPlanReportService.java | 6 +++--- .../metersphere/track/service/TestPlanService.java | 12 ++++++------ 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/commons/constants/TestPlanLoadCaseStatus.java 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);