fix(测试跟踪): 优化测试计划报告的计算方式
--bug=1019086 --user=宋天阳 #18478 测试计划关联用例多时(500多个场景用例),查看报告耗时较长(30-60s),建议优化 https://www.tapd.cn/55049933/s/1283179
This commit is contained in:
parent
b426ee51a2
commit
8c94e79ba3
|
@ -611,6 +611,7 @@ public class TestPlanLoadCaseService {
|
||||||
Map config = request.getConfig();
|
Map config = request.getConfig();
|
||||||
Map<String, String> loadCaseReportMap = request.getReportIdMap();
|
Map<String, String> loadCaseReportMap = request.getReportIdMap();
|
||||||
if (MapUtils.isEmpty(loadCaseReportMap)) {
|
if (MapUtils.isEmpty(loadCaseReportMap)) {
|
||||||
|
loadPlanReport.setLoadAllCases(new ArrayList<>());
|
||||||
return loadPlanReport;
|
return loadPlanReport;
|
||||||
}
|
}
|
||||||
if (ServiceUtils.checkConfigEnable(config, "load")) {
|
if (ServiceUtils.checkConfigEnable(config, "load")) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.plan.service;
|
package io.metersphere.plan.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
|
||||||
|
@ -557,31 +558,35 @@ public class TestPlanReportService {
|
||||||
content.setPassRate(null);
|
content.setPassRate(null);
|
||||||
extTestPlanReportMapper.setApiBaseCountAndPassRateIsNullById(content.getId());
|
extTestPlanReportMapper.setApiBaseCountAndPassRateIsNullById(content.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//更新测试计划并发送通知
|
||||||
|
testPlanReport.setIsApiCaseExecuting(false);
|
||||||
|
testPlanReport.setIsScenarioExecuting(false);
|
||||||
|
testPlanReport.setIsPerformanceExecuting(false);
|
||||||
|
testPlanReport.setIsUiScenarioExecuting(false);
|
||||||
|
//计算测试计划状态
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (StringUtils.equalsIgnoreCase(status, TestPlanReportStatus.COMPLETED.name())) {
|
||||||
|
testPlanReport.setStatus(TestPlanReportStatus.SUCCESS.name());
|
||||||
|
HttpHeaderUtils.runAsUser("admin");
|
||||||
|
testPlanService.checkStatus(testPlanReport.getTestPlanId());
|
||||||
|
} else {
|
||||||
|
testPlanReport.setStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
//更新content表对结束日期
|
//更新content表对结束日期
|
||||||
if (!StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
if (!StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), APITestStatus.Rerunning.name())) {
|
||||||
content.setStartTime(testPlanReport.getStartTime());
|
content.setStartTime(testPlanReport.getStartTime());
|
||||||
content.setEndTime(endTime);
|
content.setEndTime(endTime);
|
||||||
}
|
}
|
||||||
|
this.initTestPlanReportBaseCount(testPlanReport, content);
|
||||||
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
testPlanReportContentMapper.updateByExampleSelective(content, contentExample);
|
||||||
}
|
}
|
||||||
//计算测试计划状态
|
|
||||||
if (StringUtils.equalsIgnoreCase(status, TestPlanReportStatus.COMPLETED.name())) {
|
|
||||||
testPlanReport.setStatus(TestPlanReportStatus.SUCCESS.name());
|
|
||||||
HttpHeaderUtils.runAsUser("admin");
|
|
||||||
try {
|
|
||||||
testPlanService.checkStatus(testPlanReport.getTestPlanId());
|
|
||||||
} finally {
|
} finally {
|
||||||
HttpHeaderUtils.clearUser();
|
HttpHeaderUtils.clearUser();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
testPlanReport.setStatus(status);
|
|
||||||
}
|
|
||||||
//更新测试计划并发送通知
|
|
||||||
testPlanReport.setIsApiCaseExecuting(false);
|
|
||||||
testPlanReport.setIsScenarioExecuting(false);
|
|
||||||
testPlanReport.setIsPerformanceExecuting(false);
|
|
||||||
testPlanReport.setIsUiScenarioExecuting(false);
|
|
||||||
|
|
||||||
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
|
TestPlanExecutionQueueExample testPlanExecutionQueueExample = new TestPlanExecutionQueueExample();
|
||||||
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
|
testPlanExecutionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId);
|
||||||
|
@ -616,6 +621,13 @@ public class TestPlanReportService {
|
||||||
return testPlanReport;
|
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 planReportId 测试计划报告ID
|
||||||
* @param resourceRunMode 资源的运行模式,triggerMode非Scedule可以为null
|
* @param resourceRunMode 资源的运行模式,triggerMode非Scedule可以为null
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.metersphere.plan.service;
|
package io.metersphere.plan.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
|
@ -1263,10 +1264,10 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
TestPlanExecuteReportDTO testPlanExecuteReportDTO = testPlanReportService.genTestPlanExecuteReportDTOByTestPlanReportContent(testPlanReportContentWithBLOBs);
|
TestPlanExecuteReportDTO testPlanExecuteReportDTO = testPlanReportService.genTestPlanExecuteReportDTOByTestPlanReportContent(testPlanReportContentWithBLOBs);
|
||||||
TestPlanSimpleReportDTO report = null;
|
TestPlanSimpleReportDTO report = null;
|
||||||
|
boolean apiBaseInfoChanged = false;
|
||||||
if (StringUtils.isEmpty(testPlanReportContentWithBLOBs.getApiBaseCount())) {
|
if (StringUtils.isEmpty(testPlanReportContentWithBLOBs.getApiBaseCount())) {
|
||||||
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
||||||
testPlanReportContentWithBLOBs.setApiBaseCount(JSON.toJSONString(report));
|
apiBaseInfoChanged = true;
|
||||||
returnDTO.setApiBaseInfoChanged(true);
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
report = JSON.parseObject(testPlanReportContentWithBLOBs.getApiBaseCount(), TestPlanSimpleReportDTO.class);
|
report = JSON.parseObject(testPlanReportContentWithBLOBs.getApiBaseCount(), TestPlanSimpleReportDTO.class);
|
||||||
|
@ -1275,15 +1276,28 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
report = getReport(testPlanReport.getTestPlanId(), testPlanExecuteReportDTO);
|
||||||
testPlanReportContentWithBLOBs.setApiBaseCount(JSON.toJSONString(report));
|
apiBaseInfoChanged = true;
|
||||||
returnDTO.setApiBaseInfoChanged(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (report.getFunctionAllCases() == null || report.getIssueList() == null) {
|
||||||
buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
|
buildFunctionalReport(report, config, testPlanReport.getTestPlanId());
|
||||||
|
apiBaseInfoChanged = true;
|
||||||
|
}
|
||||||
|
if (report.getApiAllCases() == null && report.getScenarioAllCases() == null) {
|
||||||
buildApiReport(report, config, testPlanExecuteReportDTO);
|
buildApiReport(report, config, testPlanExecuteReportDTO);
|
||||||
|
apiBaseInfoChanged = true;
|
||||||
|
}
|
||||||
|
if (report.getLoadAllCases() == null) {
|
||||||
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
|
buildLoadReport(report, config, testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap(), false);
|
||||||
|
apiBaseInfoChanged = true;
|
||||||
|
}
|
||||||
buildUiReport(report, config, testPlanReport.getTestPlanId(), testPlanExecuteReportDTO, false);
|
buildUiReport(report, config, testPlanReport.getTestPlanId(), testPlanExecuteReportDTO, false);
|
||||||
returnDTO.setTestPlanSimpleReportDTO(report);
|
returnDTO.setTestPlanSimpleReportDTO(report);
|
||||||
|
|
||||||
|
if (apiBaseInfoChanged) {
|
||||||
|
testPlanReportContentWithBLOBs.setApiBaseCount(JSONObject.toJSONString(report));
|
||||||
|
returnDTO.setApiBaseInfoChanged(true);
|
||||||
|
}
|
||||||
return returnDTO;
|
return returnDTO;
|
||||||
} else {
|
} else {
|
||||||
returnDTO.setTestPlanSimpleReportDTO(new TestPlanSimpleReportDTO());
|
returnDTO.setTestPlanSimpleReportDTO(new TestPlanSimpleReportDTO());
|
||||||
|
|
Loading…
Reference in New Issue