fix(测试跟踪): 测试计划-场景/性能测试报告 不显示运行模式和资源池
--bug=1021244 --user=张勇 【测试跟踪】测试计划-报告统计-不显示运行模式和资源池 https://www.tapd.cn/55049933/s/1320602
This commit is contained in:
parent
91d395dc71
commit
dffb4c990d
|
@ -8,6 +8,7 @@ import io.metersphere.api.dto.automation.TestPlanFailureApiDTO;
|
|||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.plan.TestPlanApiCaseBatchRequest;
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiScenarioReportWithBLOBs;
|
||||
import io.metersphere.commons.constants.OperLogConstants;
|
||||
import io.metersphere.commons.constants.OperLogModule;
|
||||
import io.metersphere.commons.constants.PermissionConstants;
|
||||
|
@ -204,4 +205,10 @@ public class TestPlanApiCaseController {
|
|||
public List<ApiDefinitionExecResultWithBLOBs> selectExtForPlanReport(@PathVariable("planId") String planId) {
|
||||
return testPlanApiCaseService.selectExtForPlanReport(planId);
|
||||
}
|
||||
|
||||
@GetMapping("/get/report/scenario/ext/{planId}")
|
||||
public List<ApiScenarioReportWithBLOBs> selectExtForPlanScenarioReport(@PathVariable("planId") String planId) {
|
||||
return testPlanApiCaseService.selectExtForPlanScenarioReport(planId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import io.metersphere.api.exec.api.ApiExecuteService;
|
|||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
|
||||
|
@ -91,6 +92,8 @@ public class TestPlanApiCaseService {
|
|||
private TestPlanService testPlanService;
|
||||
@Resource
|
||||
private JMeterService jMeterService;
|
||||
@Resource
|
||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||
|
||||
public List<TestPlanApiCaseDTO> list(ApiTestCaseRequest request) {
|
||||
request.setProjectId(null);
|
||||
|
@ -818,6 +821,14 @@ public class TestPlanApiCaseService {
|
|||
return results;
|
||||
}
|
||||
|
||||
public List<ApiScenarioReportWithBLOBs> selectExtForPlanScenarioReport(String planId) {
|
||||
ApiScenarioReportExample example = new ApiScenarioReportExample();
|
||||
example.createCriteria().andRelevanceTestPlanReportIdEqualTo(planId);
|
||||
List<ApiScenarioReportWithBLOBs> results = apiScenarioReportMapper.selectByExampleWithBLOBs(example);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getApiCaseProjectIds(String planId) {
|
||||
TestPlanApiCaseExample caseExample = new TestPlanApiCaseExample();
|
||||
caseExample.createCriteria().andTestPlanIdEqualTo(planId);
|
||||
|
|
|
@ -199,4 +199,9 @@ public class TestPlanLoadCaseController {
|
|||
testPlanLoadCaseService.buildLoadResponse(cases);
|
||||
return cases;
|
||||
}
|
||||
|
||||
@GetMapping("/pool/{loadReportId}")
|
||||
public String getPlanLoadCaseResourcePoolId(@PathVariable String loadReportId) {
|
||||
return testPlanLoadCaseService.getPlanLoadCaseResourcePoolId(loadReportId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
|||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
@ -410,6 +411,17 @@ public class TestPlanLoadCaseService {
|
|||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
public String getPlanLoadCaseResourcePoolId(String loadReportId) {
|
||||
if (StringUtils.isBlank(loadReportId)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
LoadTestReportWithBLOBs loadCases = loadTestReportMapper.selectByPrimaryKey(loadReportId);
|
||||
if (loadCases != null) {
|
||||
return loadCases.getTestResourcePoolId();
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
public String getAdvancedConfiguration(String loadCaseId) {
|
||||
if (StringUtils.isBlank(loadCaseId)) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package io.metersphere.plan.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlanEnvConfig {
|
||||
private String runMode;
|
||||
}
|
|
@ -1400,4 +1400,100 @@ public class TestPlanReportService {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TestPlanSimpleReportDTO getReportOpt(String reportId) {
|
||||
TestPlanReportContentExample example = new TestPlanReportContentExample();
|
||||
example.createCriteria().andTestPlanReportIdEqualTo(reportId);
|
||||
List<TestPlanReportContentWithBLOBs> testPlanReportContents = testPlanReportContentMapper.selectByExampleWithBLOBs(example);
|
||||
if (CollectionUtils.isEmpty(testPlanReportContents)) {
|
||||
return null;
|
||||
}
|
||||
TestPlanReportContentWithBLOBs testPlanReportContent = testPlanReportContents.get(0);
|
||||
if (testPlanReportContent == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.isDynamicallyGenerateReports(testPlanReportContent)) {
|
||||
testPlanReportContent = this.dynamicallyGenerateReports(testPlanReportContent);
|
||||
}
|
||||
TestPlanSimpleReportDTO testPlanReportDTO = new TestPlanSimpleReportDTO();
|
||||
BeanUtils.copyBean(testPlanReportDTO, testPlanReportContent);
|
||||
this.generateEnvironmentInfo(testPlanReportDTO, reportId);
|
||||
|
||||
testPlanReportDTO.setFunctionResult(
|
||||
getReportContentResultObject(testPlanReportContent.getFunctionResult(), TestPlanFunctionResultReportDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setApiResult(
|
||||
getReportContentResultObject(testPlanReportContent.getApiResult(), TestPlanApiResultReportDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setLoadResult(
|
||||
getReportContentResultObject(testPlanReportContent.getLoadResult(), TestPlanLoadResultReportDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setFunctionAllCases(
|
||||
getReportContentResultArray(testPlanReportContent.getFunctionAllCases(), TestPlanCaseDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setIssueList(
|
||||
getReportContentResultArray(testPlanReportContent.getIssueList(), IssuesDao.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setApiAllCases(
|
||||
getReportContentResultArray(testPlanReportContent.getApiAllCases(), TestPlanFailureApiDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setApiFailureCases(
|
||||
getReportContentResultArray(testPlanReportContent.getApiFailureCases(), TestPlanFailureApiDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setScenarioAllCases(
|
||||
getReportContentResultArray(testPlanReportContent.getScenarioAllCases(), TestPlanFailureScenarioDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setScenarioFailureCases(
|
||||
getReportContentResultArray(testPlanReportContent.getScenarioFailureCases(), TestPlanFailureScenarioDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setLoadAllCases(
|
||||
getReportContentResultArray(testPlanReportContent.getLoadAllCases(), TestPlanLoadCaseDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setLoadFailureCases(
|
||||
getReportContentResultArray(testPlanReportContent.getLoadFailureCases(), TestPlanLoadCaseDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setErrorReportCases(
|
||||
getReportContentResultArray(testPlanReportContent.getErrorReportCases(), TestPlanFailureApiDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setErrorReportScenarios(
|
||||
getReportContentResultArray(testPlanReportContent.getErrorReportScenarios(), TestPlanFailureScenarioDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setUnExecuteCases(
|
||||
getReportContentResultArray(testPlanReportContent.getUnExecuteCases(), TestPlanFailureApiDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setUnExecuteScenarios(
|
||||
getReportContentResultArray(testPlanReportContent.getUnExecuteScenarios(), TestPlanFailureScenarioDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setUiResult(
|
||||
getReportContentResultObject(testPlanReportContent.getUiResult(), TestPlanUiResultReportDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setUiAllCases(
|
||||
getReportContentResultArray(testPlanReportContent.getUiAllCases(), TestPlanUiScenarioDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setUiFailureCases(
|
||||
getReportContentResultArray(testPlanReportContent.getUiFailureCases(), TestPlanUiScenarioDTO.class)
|
||||
);
|
||||
|
||||
testPlanReportDTO.setId(reportId);
|
||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportContent.getTestPlanReportId());
|
||||
testPlanReportDTO.setName(testPlanReport.getName());
|
||||
return testPlanReportDTO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,6 +156,8 @@ public class TestPlanService {
|
|||
private SystemParameterService systemParameterService;
|
||||
@Resource
|
||||
private BaseProjectApplicationService projectApplicationService;
|
||||
@Resource
|
||||
private TestPlanReportMapper testPlanReportMapper;
|
||||
public static final String POOL = "POOL";
|
||||
|
||||
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
|
||||
|
@ -2013,6 +2015,13 @@ public class TestPlanService {
|
|||
getResourcePool(apiDefinition.getActuator(), testPlanExtReportDTO);
|
||||
return testPlanExtReportDTO;
|
||||
}
|
||||
List<ApiScenarioReportWithBLOBs> apiScenarioLists = planTestPlanApiCaseService.selectExtForPlanScenarioReport(reportId);
|
||||
if(CollectionUtils.isNotEmpty(apiScenarioLists)){
|
||||
ApiScenarioReportWithBLOBs apiScenario = apiScenarioLists.get(0);
|
||||
convertEnvConfig(apiScenario.getEnvConfig(), testPlanExtReportDTO);
|
||||
getResourcePool(apiScenario.getActuator(), testPlanExtReportDTO);
|
||||
return testPlanExtReportDTO;
|
||||
}
|
||||
}
|
||||
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
|
||||
List<UiScenarioReportWithBLOBs> apiDefinitionLists = planTestPlanUiScenarioCaseService.selectExtForPlanReport(reportId);
|
||||
|
@ -2023,6 +2032,25 @@ public class TestPlanService {
|
|||
return testPlanExtReportDTO;
|
||||
}
|
||||
}
|
||||
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
TestPlanSimpleReportDTO testPlanSimpleReportDTO = testPlanReportService.getReportOpt(reportId);
|
||||
if (testPlanSimpleReportDTO != null) {
|
||||
List<TestPlanLoadCaseDTO> loadList = testPlanSimpleReportDTO.getLoadAllCases();
|
||||
if (CollectionUtils.isNotEmpty(loadList)) {
|
||||
String loadReportId = loadList.get(0).getLoadReportId();
|
||||
if (StringUtils.isNotEmpty(loadReportId)) {
|
||||
// 资源池
|
||||
String planLoadCaseResourcePoolId = planTestPlanLoadCaseService.getPlanLoadCaseResourcePoolId(loadReportId);
|
||||
// 运行模式
|
||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId);
|
||||
if (testPlanReport != null && StringUtils.isNotEmpty(testPlanReport.getRunInfo())) {
|
||||
convertPlanEnvConfig(testPlanReport.getRunInfo(), testPlanExtReportDTO);
|
||||
}
|
||||
getResourcePool(planLoadCaseResourcePoolId, testPlanExtReportDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return testPlanExtReportDTO;
|
||||
}
|
||||
|
||||
|
@ -2063,6 +2091,13 @@ public class TestPlanService {
|
|||
getResourcePool(apiDefinition.getActuator(), testPlanExtReportDTO);
|
||||
return testPlanExtReportDTO;
|
||||
}
|
||||
List<ApiScenarioReportWithBLOBs> apiScenarioLists = planTestPlanApiCaseService.selectExtForPlanScenarioReport(reportId);
|
||||
if(CollectionUtils.isNotEmpty(apiScenarioLists)){
|
||||
ApiScenarioReportWithBLOBs apiScenario = apiScenarioLists.get(0);
|
||||
convertEnvConfig(apiScenario.getEnvConfig(), testPlanExtReportDTO);
|
||||
getResourcePool(apiScenario.getActuator(), testPlanExtReportDTO);
|
||||
return testPlanExtReportDTO;
|
||||
}
|
||||
}
|
||||
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
|
||||
List<UiScenarioReportWithBLOBs> apiDefinitionLists = planTestPlanUiScenarioCaseService.selectExtForPlanReport(reportId);
|
||||
|
@ -2073,6 +2108,25 @@ public class TestPlanService {
|
|||
return testPlanExtReportDTO;
|
||||
}
|
||||
}
|
||||
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
TestPlanSimpleReportDTO testPlanSimpleReportDTO = testPlanReportService.getReportOpt(reportId);
|
||||
if (testPlanSimpleReportDTO != null) {
|
||||
List<TestPlanLoadCaseDTO> loadList = testPlanSimpleReportDTO.getLoadAllCases();
|
||||
if (CollectionUtils.isNotEmpty(loadList)) {
|
||||
String loadReportId = loadList.get(0).getLoadReportId();
|
||||
if (StringUtils.isNotEmpty(loadReportId)) {
|
||||
// 资源池
|
||||
String planLoadCaseResourcePoolId = planTestPlanLoadCaseService.getPlanLoadCaseResourcePoolId(loadReportId);
|
||||
// 运行模式
|
||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId);
|
||||
if (testPlanReport != null && StringUtils.isNotEmpty(testPlanReport.getRunInfo())) {
|
||||
convertPlanEnvConfig(testPlanReport.getRunInfo(), testPlanExtReportDTO);
|
||||
}
|
||||
getResourcePool(planLoadCaseResourcePoolId, testPlanExtReportDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return testPlanExtReportDTO;
|
||||
}
|
||||
|
||||
|
@ -2088,4 +2142,18 @@ public class TestPlanService {
|
|||
projectIds.addAll(apiScenarioProjectIds);
|
||||
return projectIds.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void convertPlanEnvConfig(String envConfig, TestPlanExtReportDTO testPlanExtReportDTO) throws JsonProcessingException {
|
||||
if(StringUtils.isEmpty(envConfig)){
|
||||
return;
|
||||
}
|
||||
PlanEnvConfig env = objectMapper.readValue(envConfig, PlanEnvConfig.class);
|
||||
if(StringUtils.isNotEmpty(env.getRunMode())){
|
||||
if(RunMode.RUN_MODE_SERIAL.getCode().equals(env.getRunMode())){
|
||||
testPlanExtReportDTO.setRunMode(RunMode.RUN_MODE_SERIAL.getDesc());
|
||||
} else if (RunMode.RUN_MODE_PARALLEL.getCode().equals(env.getRunMode())) {
|
||||
testPlanExtReportDTO.setRunMode(RunMode.RUN_MODE_PARALLEL.getDesc());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.plan.service.remote.api;
|
||||
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiScenarioReportWithBLOBs;
|
||||
import io.metersphere.commons.constants.MicroServiceName;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
|
@ -166,4 +167,8 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
|
|||
public List<ApiDefinitionExecResultWithBLOBs> selectExtForPlanReport(String planId) {
|
||||
return microService.getForDataArray(serviceName, BASE_UEL + "/get/report/ext/" + planId, ApiDefinitionExecResultWithBLOBs.class);
|
||||
}
|
||||
|
||||
public List<ApiScenarioReportWithBLOBs> selectExtForPlanScenarioReport(String planId) {
|
||||
return microService.getForDataArray(serviceName, BASE_UEL + "/get/report/scenario/ext/" + planId, ApiScenarioReportWithBLOBs.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,4 +129,9 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
|
|||
request.setAllowedRepeatCase(testPlanService.isAllowedRepeatCase(request.getTestPlanId()));
|
||||
return microService.postForData(serviceName, BASE_UEL + String.format("/relevance/list/%s/%s", pageNum, pageSize), request);
|
||||
}
|
||||
|
||||
public String getPlanLoadCaseResourcePoolId(String loadReportId) {
|
||||
return (String) microService.getForData(serviceName, BASE_UEL + "/pool/" + loadReportId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue