From a175e99bb82ac6e494ac1308cd7a7fb10738747d Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 7 Dec 2021 16:32:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=8A=A5=E5=91=8A):=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A=E6=80=A7=E8=83=BD=E4=B8=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=80=E7=BB=88=E7=8A=B6=E6=80=81=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复测试计划报告性能不更新最终状态的问题 --- .../commons/utils/TestPlanUtils.java | 1 + .../track/dto/TestPlanLoadCaseEventDTO.java | 1 + .../track/service/TestPlanReportService.java | 19 +++++++++++-------- .../track/service/TestPlanService.java | 6 +++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/metersphere/commons/utils/TestPlanUtils.java b/backend/src/main/java/io/metersphere/commons/utils/TestPlanUtils.java index a45fd55ede..2bb1db3996 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/TestPlanUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/TestPlanUtils.java @@ -44,6 +44,7 @@ public class TestPlanUtils { addToReportStatusResultList(resultMap, statusResult, "Fail"); addToReportStatusResultList(resultMap, statusResult, "success"); addToReportStatusResultList(resultMap, statusResult, "Success"); + addToReportStatusResultList(resultMap, statusResult, "SUCCESS"); addToReportStatusResultList(resultMap, statusResult, TestPlanTestCaseStatus.Prepare.name()); } diff --git a/backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java index a18ba21dfe..cf1583883c 100644 --- a/backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/TestPlanLoadCaseEventDTO.java @@ -14,4 +14,5 @@ public class TestPlanLoadCaseEventDTO { private String reportId; private String triggerMode; private String status; + private String id; } 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 9d198ab408..820f8f996a 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -84,6 +84,8 @@ public class TestPlanReportService { ApiTestCaseMapper apiTestCaseMapper; @Resource LoadTestReportMapper loadTestReportMapper; + @Resource + TestPlanLoadCaseMapper testPlanLoadCaseMapper; @Lazy @Resource TestPlanService testPlanService; @@ -910,8 +912,8 @@ 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(loadTestReportFromDatabase.getTestId(), TestPlanApiExecuteStatus.SUCCESS.name()); - caseReportMap.put(loadTestReportFromDatabase.getTestId(), loadTestReportId); + finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanApiExecuteStatus.SUCCESS.name()); + caseReportMap.put(performaneReportIDMap.get(loadTestReportId), loadTestReportId); performaneReportIDList.remove(loadTestReportId); } } @@ -925,13 +927,14 @@ public class TestPlanReportService { testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] SELECT performance BATCH OVER:" + JSONArray.toJSONString(selectList)); if (performaneReportIDList.isEmpty()) { testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] performance EXECUTE OVER. TRIGGER_MODE:" + triggerMode + ",REsult:" + JSONObject.toJSONString(finishLoadTestId)); - if (StringUtils.equals(triggerMode, ReportTriggerMode.API.name())) { + if (StringUtils.equalsAnyIgnoreCase(triggerMode, ReportTriggerMode.API.name() ,ReportTriggerMode.MANUAL.name())) { for (String string : finishLoadTestId.keySet()) { - TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO(); - eventDTO.setReportId(string); - eventDTO.setTriggerMode(triggerMode); - eventDTO.setStatus(PerformanceTestStatus.Completed.name()); - this.updatePerformanceTestStatus(eventDTO); + String reportId = caseReportMap.get(string); + TestPlanLoadCaseWithBLOBs updateDTO = new TestPlanLoadCaseWithBLOBs(); + updateDTO.setId(string); + updateDTO.setStatus(finishLoadTestId.get(string)); + updateDTO.setLoadReportId(reportId); + testPlanLoadCaseMapper.updateByPrimaryKeySelective(updateDTO); } } TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(testPlanReport.getId(), null, null, finishLoadTestId); 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 e860f130a1..37bd04d9c4 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1171,7 +1171,7 @@ public class TestPlanService { try { reportId = performanceTestService.run(performanceRequest); if (reportId != null) { - performaneReportIDMap.put(reportId, caseID); + performaneReportIDMap.put(reportId, id); TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs(); testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId()); testPlanLoadCase.setLoadReportId(reportId); @@ -1189,9 +1189,9 @@ public class TestPlanService { } performaneThreadIDMap.put(performanceRequest.getTestPlanLoadId(), reportId); if (StringUtils.isNotEmpty(reportId)) { - executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.RUNNING.name()); + executePerformanceIdMap.put(performanceRequest.getTestPlanLoadId(), TestPlanApiExecuteStatus.RUNNING.name()); } else { - executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.PREPARE.name()); + executePerformanceIdMap.put(performanceRequest.getTestPlanLoadId(), TestPlanApiExecuteStatus.PREPARE.name()); } } TestPlanReportExecuteCatch.updateTestPlanThreadInfo(planReportId, null, null, performaneThreadIDMap);