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, "success");
addToReportStatusResultList(resultMap, statusResult, "Success");
addToReportStatusResultList(resultMap, statusResult, "SUCCESS");
addToReportStatusResultList(resultMap, statusResult, TestPlanTestCaseStatus.Prepare.name());
}

View File

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

View File

@ -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);

View File

@ -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);