fix(测试计划报告): 修复测试计划报告性能不更新最终状态的问题

修复测试计划报告性能不更新最终状态的问题
This commit is contained in:
song-tianyang 2021-12-07 16:32:21 +08:00 committed by song-tianyang
parent c81d701060
commit a175e99bb8
4 changed files with 16 additions and 11 deletions

View File

@ -44,6 +44,7 @@ public class TestPlanUtils {
addToReportStatusResultList(resultMap, statusResult, "Fail"); addToReportStatusResultList(resultMap, statusResult, "Fail");
addToReportStatusResultList(resultMap, statusResult, "success"); addToReportStatusResultList(resultMap, statusResult, "success");
addToReportStatusResultList(resultMap, statusResult, "Success"); addToReportStatusResultList(resultMap, statusResult, "Success");
addToReportStatusResultList(resultMap, statusResult, "SUCCESS");
addToReportStatusResultList(resultMap, statusResult, TestPlanTestCaseStatus.Prepare.name()); addToReportStatusResultList(resultMap, statusResult, TestPlanTestCaseStatus.Prepare.name());
} }

View File

@ -14,4 +14,5 @@ public class TestPlanLoadCaseEventDTO {
private String reportId; private String reportId;
private String triggerMode; private String triggerMode;
private String status; private String status;
private String id;
} }

View File

@ -84,6 +84,8 @@ public class TestPlanReportService {
ApiTestCaseMapper apiTestCaseMapper; ApiTestCaseMapper apiTestCaseMapper;
@Resource @Resource
LoadTestReportMapper loadTestReportMapper; LoadTestReportMapper loadTestReportMapper;
@Resource
TestPlanLoadCaseMapper testPlanLoadCaseMapper;
@Lazy @Lazy
@Resource @Resource
TestPlanService testPlanService; TestPlanService testPlanService;
@ -910,8 +912,8 @@ public class TestPlanReportService {
testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] SELECT performance ID:" + loadTestReportId + ",RESULT :" + loadTestReportFromDatabase.getStatus()); testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] SELECT performance ID:" + loadTestReportId + ",RESULT :" + loadTestReportFromDatabase.getStatus());
if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(), if (StringUtils.equalsAny(loadTestReportFromDatabase.getStatus(),
PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) { PerformanceTestStatus.Completed.name(), PerformanceTestStatus.Error.name())) {
finishLoadTestId.put(loadTestReportFromDatabase.getTestId(), TestPlanApiExecuteStatus.SUCCESS.name()); finishLoadTestId.put(performaneReportIDMap.get(loadTestReportId), TestPlanApiExecuteStatus.SUCCESS.name());
caseReportMap.put(loadTestReportFromDatabase.getTestId(), loadTestReportId); caseReportMap.put(performaneReportIDMap.get(loadTestReportId), loadTestReportId);
performaneReportIDList.remove(loadTestReportId); performaneReportIDList.remove(loadTestReportId);
} }
} }
@ -925,13 +927,14 @@ public class TestPlanReportService {
testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] SELECT performance BATCH OVER:" + JSONArray.toJSONString(selectList)); testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] SELECT performance BATCH OVER:" + JSONArray.toJSONString(selectList));
if (performaneReportIDList.isEmpty()) { if (performaneReportIDList.isEmpty()) {
testPlanLog.info("TestPlanReportId[" + testPlanReport.getId() + "] performance EXECUTE OVER. TRIGGER_MODE:" + triggerMode + ",REsult:" + JSONObject.toJSONString(finishLoadTestId)); 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()) { for (String string : finishLoadTestId.keySet()) {
TestPlanLoadCaseEventDTO eventDTO = new TestPlanLoadCaseEventDTO(); String reportId = caseReportMap.get(string);
eventDTO.setReportId(string); TestPlanLoadCaseWithBLOBs updateDTO = new TestPlanLoadCaseWithBLOBs();
eventDTO.setTriggerMode(triggerMode); updateDTO.setId(string);
eventDTO.setStatus(PerformanceTestStatus.Completed.name()); updateDTO.setStatus(finishLoadTestId.get(string));
this.updatePerformanceTestStatus(eventDTO); updateDTO.setLoadReportId(reportId);
testPlanLoadCaseMapper.updateByPrimaryKeySelective(updateDTO);
} }
} }
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(testPlanReport.getId(), null, null, finishLoadTestId); TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(testPlanReport.getId(), null, null, finishLoadTestId);

View File

@ -1171,7 +1171,7 @@ public class TestPlanService {
try { try {
reportId = performanceTestService.run(performanceRequest); reportId = performanceTestService.run(performanceRequest);
if (reportId != null) { if (reportId != null) {
performaneReportIDMap.put(reportId, caseID); performaneReportIDMap.put(reportId, id);
TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs(); TestPlanLoadCaseWithBLOBs testPlanLoadCase = new TestPlanLoadCaseWithBLOBs();
testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId()); testPlanLoadCase.setId(performanceRequest.getTestPlanLoadId());
testPlanLoadCase.setLoadReportId(reportId); testPlanLoadCase.setLoadReportId(reportId);
@ -1189,9 +1189,9 @@ public class TestPlanService {
} }
performaneThreadIDMap.put(performanceRequest.getTestPlanLoadId(), reportId); performaneThreadIDMap.put(performanceRequest.getTestPlanLoadId(), reportId);
if (StringUtils.isNotEmpty(reportId)) { if (StringUtils.isNotEmpty(reportId)) {
executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.RUNNING.name()); executePerformanceIdMap.put(performanceRequest.getTestPlanLoadId(), TestPlanApiExecuteStatus.RUNNING.name());
} else { } else {
executePerformanceIdMap.put(caseID, TestPlanApiExecuteStatus.PREPARE.name()); executePerformanceIdMap.put(performanceRequest.getTestPlanLoadId(), TestPlanApiExecuteStatus.PREPARE.name());
} }
} }
TestPlanReportExecuteCatch.updateTestPlanThreadInfo(planReportId, null, null, performaneThreadIDMap); TestPlanReportExecuteCatch.updateTestPlanThreadInfo(planReportId, null, null, performaneThreadIDMap);