fix(测试跟踪): 优化测试计划报告查看速度
--bug=1019086 --user=宋天阳 #18478 测试计划关联用例多时(500多个场景用例),查看报告耗时较长(30-60s),建议优化 https://www.tapd.cn/55049933/s/1283179
This commit is contained in:
parent
4950bf9575
commit
cdc3708fe8
|
@ -558,14 +558,6 @@ public class TestPlanReportService {
|
|||
content.setPassRate(null);
|
||||
extTestPlanReportMapper.setApiBaseCountAndPassRateIsNullById(content.getId());
|
||||
}
|
||||
if (content != null) {
|
||||
//更新content表对结束日期
|
||||
if (!StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
||||
content.setStartTime(testPlanReport.getStartTime());
|
||||
content.setEndTime(endTime);
|
||||
}
|
||||
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
||||
}
|
||||
//计算测试计划状态
|
||||
if (StringUtils.equalsIgnoreCase(status, TestPlanReportStatus.COMPLETED.name())) {
|
||||
testPlanReport.setStatus(TestPlanReportStatus.SUCCESS.name());
|
||||
|
@ -578,6 +570,16 @@ public class TestPlanReportService {
|
|||
testPlanReport.setIsPerformanceExecuting(false);
|
||||
testPlanReport.setIsUiScenarioExecuting(false);
|
||||
|
||||
if (content != null) {
|
||||
//更新content表对结束日期,并计算报表信息
|
||||
if (!StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
||||
content.setStartTime(testPlanReport.getStartTime());
|
||||
content.setEndTime(endTime);
|
||||
}
|
||||
this.initTestPlanReportBaseCount(testPlanReport,content);
|
||||
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
||||
}
|
||||
|
||||
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
|
||||
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
|
||||
List<TestPlanExecutionQueue> planExecutionQueues = testPlanExecutionQueueMapper.selectByExample(testPlanExecutionQueueExample);
|
||||
|
@ -611,6 +613,13 @@ public class TestPlanReportService {
|
|||
return testPlanReport;
|
||||
}
|
||||
|
||||
private void initTestPlanReportBaseCount(TestPlanReport testPlanReport,TestPlanReportContentWithBLOBs reportContent) {
|
||||
if(testPlanReport != null && reportContent != null){
|
||||
TestPlanReportBuildResultDTO reportBuildResultDTO = testPlanService.buildPlanReport(testPlanReport, reportContent);
|
||||
reportContent.setApiBaseCount(JSONObject.toJSONString(reportBuildResultDTO.getTestPlanSimpleReportDTO()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param planReportId 测试计划报告ID
|
||||
* @param resourceRunMode 资源的运行模式,triggerMode非Scedule可以为null
|
||||
|
|
|
@ -1881,6 +1881,7 @@ public class TestPlanService {
|
|||
|
||||
public void buildLoadReport(TestPlanSimpleReportDTO report, JSONObject config, Map<String, String> loadCaseReportMap, boolean saveResponse) {
|
||||
if (MapUtils.isEmpty(loadCaseReportMap)) {
|
||||
report.setLoadAllCases(new ArrayList<>());
|
||||
return;
|
||||
}
|
||||
if (checkReportConfig(config, "load")) {
|
||||
|
@ -1921,10 +1922,10 @@ public class TestPlanService {
|
|||
}
|
||||
TestPlanExecuteReportDTO testPlanExecuteReportDTO = testPlanReportService.genTestPlanExecuteReportDTOByTestPlanReportContent(testPlanReportContentWithBLOBs);
|
||||
TestPlanSimpleReportDTO report = null;
|
||||
boolean apiBaseInfoChanged = false;
|
||||
if (StringUtils.isEmpty(testPlanReportContentWithBLOBs.getApiBaseCount())) {
|
||||
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
||||
testPlanReportContentWithBLOBs.setApiBaseCount(JSONObject.toJSONString(report));
|
||||
returnDTO.setApiBaseInfoChanged(true);
|
||||
apiBaseInfoChanged = true;
|
||||
} else {
|
||||
try {
|
||||
report = JSONObject.parseObject(testPlanReportContentWithBLOBs.getApiBaseCount(), TestPlanSimpleReportDTO.class);
|
||||
|
@ -1933,15 +1934,29 @@ public class TestPlanService {
|
|||
}
|
||||
if (report == null) {
|
||||
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
||||
testPlanReportContentWithBLOBs.setApiBaseCount(JSONObject.toJSONString(report));
|
||||
returnDTO.setApiBaseInfoChanged(true);
|
||||
apiBaseInfoChanged = true;
|
||||
}
|
||||
}
|
||||
buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
|
||||
buildApiReport(report, config, testPlanExecuteReportDTO);
|
||||
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
|
||||
if(report.getFunctionAllCases() == null || report.getIssueList() == null){
|
||||
buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
|
||||
apiBaseInfoChanged = true;
|
||||
}
|
||||
if(report.getApiAllCases() == null && report.getScenarioAllCases() == null){
|
||||
buildApiReport(report, config, testPlanExecuteReportDTO);
|
||||
apiBaseInfoChanged = true;
|
||||
}
|
||||
if(report.getLoadAllCases() == null){
|
||||
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
|
||||
apiBaseInfoChanged = true;
|
||||
}
|
||||
buildUiReport(report, config, testPlanReport.getTestPlanId(), testPlanExecuteReportDTO, false);
|
||||
returnDTO.setTestPlanSimpleReportDTO(report);
|
||||
|
||||
if(apiBaseInfoChanged){
|
||||
testPlanReportContentWithBLOBs.setApiBaseCount(JSONObject.toJSONString(report));
|
||||
returnDTO.setApiBaseInfoChanged(true);
|
||||
}
|
||||
|
||||
return returnDTO;
|
||||
} else {
|
||||
returnDTO.setTestPlanSimpleReportDTO(new TestPlanSimpleReportDTO());
|
||||
|
|
Loading…
Reference in New Issue