fix(测试跟踪): 优化UI报告的查询方式

https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001024331
This commit is contained in:
song-tianyang 2023-03-14 17:37:26 +08:00 committed by 建国
parent 2c36fdaad8
commit 2d2bf40b3a
5 changed files with 68 additions and 12 deletions

View File

@ -0,0 +1,18 @@
package io.metersphere.plan.request.ui;
import io.metersphere.dto.TestPlanUiScenarioDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Map;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class TestPlanUiExecuteReportDTO {
private Map<String, String> testPlanUiScenarioIdAndReportIdMap;
private Map<String, TestPlanUiScenarioDTO> uiScenarioInfoDTOMap;
}

View File

@ -0,0 +1,12 @@
package io.metersphere.plan.request.ui;
import io.metersphere.request.PlanSubReportRequest;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class UiPlanReportRequest extends PlanSubReportRequest {
private TestPlanUiExecuteReportDTO testPlanExecuteReportDTO;
}

View File

@ -21,6 +21,8 @@ import io.metersphere.plan.request.TestPlanReportSaveRequest;
import io.metersphere.plan.request.api.ApiPlanReportRequest;
import io.metersphere.plan.request.api.TestPlanRunRequest;
import io.metersphere.plan.request.performance.LoadPlanReportDTO;
import io.metersphere.plan.request.ui.TestPlanUiExecuteReportDTO;
import io.metersphere.plan.request.ui.UiPlanReportRequest;
import io.metersphere.plan.service.remote.api.*;
import io.metersphere.plan.service.remote.performance.PlanLoadTestReportService;
import io.metersphere.plan.service.remote.performance.PlanTestPlanLoadCaseService;
@ -1267,6 +1269,28 @@ public class TestPlanReportService {
return returnMap;
}
private TestPlanUiExecuteReportDTO parseUiCaseReportMap(String reportStructStr) {
TestPlanUiExecuteReportDTO uiExecuteReportDTO = new TestPlanUiExecuteReportDTO();
if (StringUtils.isNotEmpty(reportStructStr)) {
Map<String, String> uiReportMap = new HashMap<>();
Map<String, TestPlanUiScenarioDTO> uiDTOMap = new HashMap<>();
List<TestPlanUiScenarioDTO> testPlanUiScenarioDTOList = null;
try {
testPlanUiScenarioDTOList = JSON.parseArray(reportStructStr, TestPlanUiScenarioDTO.class);
} catch (Exception ignored) {
}
if (CollectionUtils.isNotEmpty(testPlanUiScenarioDTOList)) {
for (TestPlanUiScenarioDTO dto : testPlanUiScenarioDTOList) {
uiReportMap.put(dto.getId(), dto.getReportId());
uiDTOMap.put(dto.getId(), dto);
}
}
uiExecuteReportDTO.setTestPlanUiScenarioIdAndReportIdMap(uiReportMap);
uiExecuteReportDTO.setUiScenarioInfoDTOMap(uiDTOMap);
}
return uiExecuteReportDTO;
}
private Map<String, String> parseCaseReportMap(String reportStructStr) {
Map<String, String> returnMap = new HashMap<>();
if (StringUtils.isNotEmpty(reportStructStr)) {
@ -1343,15 +1367,15 @@ public class TestPlanReportService {
//查找UI测试报告结果
if (DiscoveryUtil.hasService(MicroServiceName.UI_TEST)) {
LogUtil.info("测试计划报告【" + testPlanReportContentWithBLOBs.getTestPlanReportId() + "】开始查找UI测试报告结果");
Map<String, String> testPlanUiCaseIdAndReportIdMap = this.parseCaseReportMap(testPlanReportContentWithBLOBs.getPlanUiScenarioReportStruct());
if (MapUtils.isNotEmpty(testPlanUiCaseIdAndReportIdMap)) {
ApiPlanReportRequest request = new ApiPlanReportRequest();
request.setConfig(reportConfig);
request.setPlanId(testPlanId);
request.setSaveResponse(null);
request.setTestPlanExecuteReportDTO(reportDetailDTO);
TestPlanUiExecuteReportDTO uiExecuteReportDTO = this.parseUiCaseReportMap(testPlanReportContentWithBLOBs.getPlanUiScenarioReportStruct());
if (MapUtils.isNotEmpty(uiExecuteReportDTO.getTestPlanUiScenarioIdAndReportIdMap())
&& MapUtils.isNotEmpty(uiExecuteReportDTO.getUiScenarioInfoDTOMap())) {
UiPlanReportRequest planSubReportRequest = new UiPlanReportRequest();
planSubReportRequest.setTestPlanExecuteReportDTO(uiExecuteReportDTO);
planSubReportRequest.setConfig(reportConfig);
planSubReportRequest.setSaveResponse(false);
try {
UiPlanReportDTO uiReport = planTestPlanUiScenarioCaseService.getUiReport(request);
UiPlanReportDTO uiReport = planTestPlanUiScenarioCaseService.getUiReport(planSubReportRequest);
reportDetailDTO.setUiPlanReportDTO(uiReport);
} catch (Exception e) {
LogUtil.error("连接Ui-test查找报告结果信息失败!", e);

View File

@ -38,6 +38,8 @@ import io.metersphere.plan.request.function.PlanCaseRelevanceRequest;
import io.metersphere.plan.request.function.QueryTestPlanCaseRequest;
import io.metersphere.plan.request.performance.LoadPlanReportDTO;
import io.metersphere.plan.request.ui.RunUiScenarioRequest;
import io.metersphere.plan.request.ui.TestPlanUiExecuteReportDTO;
import io.metersphere.plan.request.ui.UiPlanReportRequest;
import io.metersphere.plan.service.remote.api.PlanApiAutomationService;
import io.metersphere.plan.service.remote.api.PlanTestPlanApiCaseService;
import io.metersphere.plan.service.remote.api.PlanTestPlanScenarioCaseService;
@ -1294,8 +1296,8 @@ public class TestPlanService {
}
}
public void buildUiReport(TestPlanReportDataStruct report, Map config, String planId, TestPlanCaseReportResultDTO testPlanExecuteReportDTO, boolean saveResponse) {
ApiPlanReportRequest request = new ApiPlanReportRequest();
public void buildUiReport(TestPlanReportDataStruct report, Map config, String planId, TestPlanUiExecuteReportDTO testPlanExecuteReportDTO, boolean saveResponse) {
UiPlanReportRequest request = new UiPlanReportRequest();
request.setConfig(config);
request.setPlanId(planId);
request.setSaveResponse(saveResponse);

View File

@ -9,8 +9,8 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.*;
import io.metersphere.plan.constant.ApiReportStatus;
import io.metersphere.plan.dto.*;
import io.metersphere.plan.request.api.ApiPlanReportRequest;
import io.metersphere.plan.request.api.ApiScenarioRequest;
import io.metersphere.plan.request.ui.UiPlanReportRequest;
import io.metersphere.plan.service.TestPlanService;
import io.metersphere.plan.service.remote.api.PlanTestPlanScenarioCaseService;
import io.metersphere.plan.service.remote.api.PlanUiScenarioReportService;
@ -45,7 +45,7 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService {
return (List<String>) microService.getForData(serviceName, BASE_URL + "/plan/exec/result/" + planId);
}
public UiPlanReportDTO getUiReport(ApiPlanReportRequest request) {
public UiPlanReportDTO getUiReport(UiPlanReportRequest request) {
return microService.postForData(serviceName, BASE_URL + "/plan/report", request, UiPlanReportDTO.class);
}