fix(测试计划): 修复测试计划报告内统计性能测试整体执行报表数据不对的问题
修复测试计划报告内统计性能测试整体执行报表数据不对的问题
This commit is contained in:
parent
3be6a8e482
commit
2d525c0fd2
|
@ -10,6 +10,7 @@ import io.metersphere.base.mapper.TestPlanLoadCaseMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
|
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
|
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
|
||||||
|
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||||
import io.metersphere.commons.constants.ReportTriggerMode;
|
import io.metersphere.commons.constants.ReportTriggerMode;
|
||||||
import io.metersphere.commons.constants.TestPlanLoadCaseStatus;
|
import io.metersphere.commons.constants.TestPlanLoadCaseStatus;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
|
@ -26,6 +27,7 @@ import io.metersphere.plan.service.remote.TestPlanService;
|
||||||
import io.metersphere.request.*;
|
import io.metersphere.request.*;
|
||||||
import io.metersphere.service.*;
|
import io.metersphere.service.*;
|
||||||
import io.metersphere.xpack.resourcepool.service.ValidQuotaResourcePoolService;
|
import io.metersphere.xpack.resourcepool.service.ValidQuotaResourcePoolService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
|
@ -34,9 +36,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.mybatis.spring.SqlSessionUtils;
|
import org.mybatis.spring.SqlSessionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -378,6 +378,8 @@ public class TestPlanLoadCaseService {
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(status)) {
|
if (StringUtils.isEmpty(status)) {
|
||||||
status = Translator.get("not_execute");
|
status = Translator.get("not_execute");
|
||||||
|
} else if (StringUtils.equals(PerformanceTestStatus.Completed.name(), status)) {
|
||||||
|
status = TestPlanLoadCaseStatus.success.name();
|
||||||
}
|
}
|
||||||
loadCaseDTO.setReportId(reportID);
|
loadCaseDTO.setReportId(reportID);
|
||||||
loadCaseDTO.setLoadReportId(reportID);
|
loadCaseDTO.setLoadReportId(reportID);
|
||||||
|
|
|
@ -1370,8 +1370,7 @@ public class TestPlanService {
|
||||||
TestPlanCaseReportResultDTO testPlanExecuteReportDTO = testPlanReportService.selectCaseDetailByTestPlanReport(config, testPlan.getId(), testPlanReportContentWithBLOBs);
|
TestPlanCaseReportResultDTO testPlanExecuteReportDTO = testPlanReportService.selectCaseDetailByTestPlanReport(config, testPlan.getId(), testPlanReportContentWithBLOBs);
|
||||||
report = generateTestPlanReport(
|
report = generateTestPlanReport(
|
||||||
config,
|
config,
|
||||||
testPlanReport.getCreator(),
|
testPlanReport,
|
||||||
StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), TestPlanReportStatus.COMPLETED.name(), TestPlanReportStatus.SUCCESS.name(), TestPlanReportStatus.FAILED.name()),
|
|
||||||
testPlan, testPlanExecuteReportDTO);
|
testPlan, testPlanExecuteReportDTO);
|
||||||
}
|
}
|
||||||
returnDTO.setTestPlanSimpleReportDTO(report);
|
returnDTO.setTestPlanSimpleReportDTO(report);
|
||||||
|
@ -1488,17 +1487,20 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//根据用例运行结果生成测试计划报告
|
//根据用例运行结果生成测试计划报告
|
||||||
public TestPlanSimpleReportDTO generateTestPlanReport(Map reportConfig, String operator, boolean isTestPlanReportExecuteOver, TestPlanWithBLOBs testPlan, TestPlanCaseReportResultDTO testPlanCaseReportResultDTO) {
|
public TestPlanSimpleReportDTO generateTestPlanReport(Map reportConfig, TestPlanReport testPlanReport, TestPlanWithBLOBs testPlan, TestPlanCaseReportResultDTO testPlanCaseReportResultDTO) {
|
||||||
TestPlanSimpleReportDTO report = new TestPlanSimpleReportDTO();
|
TestPlanSimpleReportDTO report = new TestPlanSimpleReportDTO();
|
||||||
if (ObjectUtils.anyNotNull(testPlan, testPlanCaseReportResultDTO)) {
|
if (ObjectUtils.anyNotNull(testPlan, testPlanReport, testPlanCaseReportResultDTO)) {
|
||||||
TestPlanFunctionResultReportDTO functionResult = new TestPlanFunctionResultReportDTO();
|
TestPlanFunctionResultReportDTO functionResult = new TestPlanFunctionResultReportDTO();
|
||||||
TestPlanApiResultReportDTO apiResult = new TestPlanApiResultReportDTO();
|
TestPlanApiResultReportDTO apiResult = new TestPlanApiResultReportDTO();
|
||||||
TestPlanUiResultReportDTO uiResult = new TestPlanUiResultReportDTO();
|
TestPlanUiResultReportDTO uiResult = new TestPlanUiResultReportDTO();
|
||||||
report.setFunctionResult(functionResult);
|
report.setFunctionResult(functionResult);
|
||||||
report.setApiResult(apiResult);
|
report.setApiResult(apiResult);
|
||||||
report.setUiResult(uiResult);
|
report.setUiResult(uiResult);
|
||||||
report.setStartTime(testPlan.getActualStartTime());
|
report.setStartTime(testPlanReport.getCreateTime());
|
||||||
report.setEndTime(testPlan.getActualEndTime());
|
if (testPlanReport.getCreateTime() != testPlanReport.getEndTime() && testPlanReport.getEndTime() != 0) {
|
||||||
|
//防止测试计划报告非正常状态停止时造成的测试时间显示不对
|
||||||
|
report.setEndTime(testPlanReport.getEndTime());
|
||||||
|
}
|
||||||
report.setSummary(testPlan.getReportSummary());
|
report.setSummary(testPlan.getReportSummary());
|
||||||
report.setConfig(testPlan.getReportConfig());
|
report.setConfig(testPlan.getReportConfig());
|
||||||
|
|
||||||
|
@ -1517,7 +1519,11 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
//功能用例的状态更新以及统计
|
//功能用例的状态更新以及统计
|
||||||
testPlanTestCaseService.calculateReportByTestCaseList(operator, testPlan, isTestPlanReportExecuteOver, testPlanCaseReportResultDTO.getFunctionCaseList(), report);
|
testPlanTestCaseService.calculateReportByTestCaseList(
|
||||||
|
testPlanReport.getCreator(),
|
||||||
|
testPlan,
|
||||||
|
StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), TestPlanReportStatus.COMPLETED.name(), TestPlanReportStatus.SUCCESS.name(), TestPlanReportStatus.FAILED.name()),
|
||||||
|
testPlanCaseReportResultDTO.getFunctionCaseList(), report);
|
||||||
if (report.getFunctionAllCases() == null || report.getIssueList() == null) {
|
if (report.getFunctionAllCases() == null || report.getIssueList() == null) {
|
||||||
//构建功能用例和issue
|
//构建功能用例和issue
|
||||||
this.buildFunctionalReport(report, reportConfig, testPlan.getId());
|
this.buildFunctionalReport(report, reportConfig, testPlan.getId());
|
||||||
|
|
|
@ -60,15 +60,6 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculatePlanReport(List<String> reportIds, TestPlanSimpleReportDTO report) {
|
|
||||||
try {
|
|
||||||
List<PlanReportCaseDTO> planReportCaseDTOs = planLoadTestReportService.getPlanReportCaseDTO(reportIds);
|
|
||||||
calculatePlanReport(report, planReportCaseDTOs);
|
|
||||||
} catch (MSException e) {
|
|
||||||
LogUtil.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculatePlanReport(TestPlanSimpleReportDTO report, List<PlanReportCaseDTO> planReportCaseDTOS) {
|
private void calculatePlanReport(TestPlanSimpleReportDTO report, List<PlanReportCaseDTO> planReportCaseDTOS) {
|
||||||
TestPlanLoadResultReportDTO loadResult = new TestPlanLoadResultReportDTO();
|
TestPlanLoadResultReportDTO loadResult = new TestPlanLoadResultReportDTO();
|
||||||
report.setLoadResult(loadResult);
|
report.setLoadResult(loadResult);
|
||||||
|
|
Loading…
Reference in New Issue