feat(接口测试): 测试报告增加展示运行环境信息

--story=1006994 --user=宋天阳 【通用功能】测试报告增加展示运行环境信息
https://www.tapd.cn/55049933/s/1198098
This commit is contained in:
song-tianyang 2022-05-23 09:00:38 +08:00 committed by TIanyang
parent 736657536f
commit e391fd2f90
42 changed files with 1903 additions and 1162 deletions

View File

@ -5,7 +5,6 @@ import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Setter
@Getter

View File

@ -2,6 +2,7 @@ package io.metersphere.api.dto;
import lombok.Data;
import java.util.LinkedHashMap;
import java.util.List;
@Data
@ -37,4 +38,7 @@ public class ApiScenarioReportDTO {
private String name;
private String envConfig;
//<项目名称<环境名称>>
private LinkedHashMap<String, List<String>> projectEnvMap;
}

View File

@ -0,0 +1,15 @@
package io.metersphere.api.dto;
import io.metersphere.dto.RunModeConfigDTO;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class RunModeConfigWithEnvironmentDTO extends RunModeConfigDTO {
// 接口/用例在运行时采用的环境信息 <项目ID , <环境ID>>
private Map<String, List<String>> executionEnvironmentMap;
}

View File

@ -2,6 +2,7 @@ package io.metersphere.api.exec.api;
import com.alibaba.fastjson.JSON;
import io.metersphere.api.dto.ApiCaseRunRequest;
import io.metersphere.api.dto.RunModeConfigWithEnvironmentDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.BatchRunDefinitionRequest;
import io.metersphere.api.dto.scenario.DatabaseConfig;
@ -25,6 +26,7 @@ import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ReportTypeConstants;
import io.metersphere.commons.constants.TriggerMode;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.constants.RunModeConstants;
@ -112,7 +114,18 @@ public class ApiCaseExecuteService {
if (!request.isRerun()) {
Map<String, String> planProjects = new HashMap<>();
for (TestPlanApiCase testPlanApiCase : planApiCases) {
ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.addResult(request, testPlanApiCase, status, caseMap, resourcePoolId);
//处理环境配置为空时的情况
RunModeConfigDTO runModeConfigDTO = new RunModeConfigDTO();
BeanUtils.copyBean(runModeConfigDTO, request.getConfig());
if (MapUtils.isEmpty(runModeConfigDTO.getEnvMap())) {
ApiTestCase testCase = caseMap.get(testPlanApiCase.getApiCaseId());
if (testCase != null) {
runModeConfigDTO.setEnvMap(new HashMap<>() {{
this.put(testCase.getProjectId(), testPlanApiCase.getEnvironmentId());
}});
}
}
ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.addResult(request, runModeConfigDTO, testPlanApiCase, status, caseMap, resourcePoolId);
if (planProjects.containsKey(testPlanApiCase.getTestPlanId())) {
report.setProjectId(planProjects.get(testPlanApiCase.getTestPlanId()));
} else {
@ -153,7 +166,8 @@ public class ApiCaseExecuteService {
return responseDTOS;
}
public void checkEnv(List<ApiTestCaseWithBLOBs> caseList) {
public Map<String, List<String>> checkEnv(List<ApiTestCaseWithBLOBs> caseList) {
Map<String, List<String>> projectEnvMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(caseList)) {
StringBuilder builderHttp = new StringBuilder();
StringBuilder builderTcp = new StringBuilder();
@ -163,6 +177,18 @@ public class ApiCaseExecuteService {
if (apiCaseNew.has("type") && "HTTPSamplerProxy".equals(apiCaseNew.getString("type"))) {
if (!apiCaseNew.has("useEnvironment") || StringUtils.isEmpty(apiCaseNew.getString("useEnvironment"))) {
builderHttp.append(apiCase.getName()).append("; ");
} else {
//记录运行环境ID
String envId = apiCaseNew.getString("useEnvironment");
if (projectEnvMap.containsKey(apiCase.getProjectId())) {
if (!projectEnvMap.get(apiCase.getProjectId()).contains(envId)) {
projectEnvMap.get(apiCase.getProjectId()).add(envId);
}
} else {
projectEnvMap.put(apiCase.getProjectId(), new ArrayList<>() {{
this.add(envId);
}});
}
}
}
if (apiCaseNew.has("type") && "JDBCSampler".equals(apiCaseNew.getString("type"))) {
@ -179,6 +205,16 @@ public class ApiCaseExecuteService {
for (DatabaseConfig item : envConfig.getDatabaseConfigs()) {
if (item.getId().equals(dataSourceId)) {
dataSource = item;
//记录运行环境ID
if (projectEnvMap.containsKey(apiCase.getProjectId())) {
if (!projectEnvMap.get(apiCase.getProjectId()).contains(environmentId)) {
projectEnvMap.get(apiCase.getProjectId()).add(environmentId);
}
} else {
projectEnvMap.put(apiCase.getProjectId(), new ArrayList<>() {{
this.add(environmentId);
}});
}
}
}
}
@ -196,6 +232,7 @@ public class ApiCaseExecuteService {
MSException.throwException("用例:" + builderTcp + "数据源为空!请检查");
}
}
return projectEnvMap;
}
/**
@ -225,16 +262,25 @@ public class ApiCaseExecuteService {
example.createCriteria().andIdIn(request.getIds()).andStatusNotEqualTo("Trash");
List<ApiTestCaseWithBLOBs> caseList = apiTestCaseMapper.selectByExampleWithBLOBs(example);
LoggerUtil.debug("查询到执行数据:" + caseList.size());
Map<String, List<String>> testCaseEnvMap = new HashMap<>();
// 环境检查
if (MapUtils.isEmpty(request.getConfig().getEnvMap())) {
this.checkEnv(caseList);
testCaseEnvMap = this.checkEnv(caseList);
}
// 集合报告设置
String serialReportId = request.isRerun() ? request.getReportId() : null;
if (!request.isRerun() && StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString())
&& StringUtils.isNotEmpty(request.getConfig().getReportName())) {
serialReportId = UUID.randomUUID().toString();
ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.initBase(null, APITestStatus.Running.name(), serialReportId, request.getConfig());
RunModeConfigDTO config = request.getConfig();
if (MapUtils.isEmpty(config.getEnvMap())) {
RunModeConfigWithEnvironmentDTO runModeConfig = new RunModeConfigWithEnvironmentDTO();
BeanUtils.copyBean(runModeConfig, request.getConfig());
this.setExecutionEnvironmen(runModeConfig, testCaseEnvMap);
config = runModeConfig;
}
ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.initBase(null, APITestStatus.Running.name(), serialReportId, config);
report.setName(request.getConfig().getReportName());
report.setProjectId(request.getProjectId());
report.setReportType(ReportTypeConstants.API_INTEGRATED.name());
@ -313,4 +359,28 @@ public class ApiCaseExecuteService {
}
return responseDTOS;
}
public void setExecutionEnvironmen(RunModeConfigWithEnvironmentDTO config, Map<String, List<String>> projectEnvMap) {
if (MapUtils.isNotEmpty(projectEnvMap) && config != null) {
config.setExecutionEnvironmentMap(projectEnvMap);
}
}
public void setRunModeConfigEnvironment(RunModeConfigWithEnvironmentDTO config, Map<String, String> projectEnvMap) {
if (MapUtils.isNotEmpty(projectEnvMap) && config != null) {
Map<String, List<String>> executionEnvMap = new HashMap<>();
for (Map.Entry<String, String> entry : projectEnvMap.entrySet()) {
String projectId = entry.getKey();
String envId = entry.getValue();
if (StringUtils.isNoneEmpty(projectId, envId)) {
executionEnvMap.put(projectId, new ArrayList<>() {{
this.add(envId);
}});
}
}
if (MapUtils.isNotEmpty(executionEnvMap)) {
config.setExecutionEnvironmentMap(executionEnvMap);
}
}
}
}

View File

@ -29,10 +29,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -277,7 +274,15 @@ public class ApiScenarioEnvService {
}
}
public void checkEnv(RunScenarioRequest request, List<ApiScenarioWithBLOBs> apiScenarios) {
/**
* 检查是否存在运行环境若不存在则报错存在的话返回所存在的运行环境
*
* @param request
* @param apiScenarios
* @return <projectId,envIds>
*/
public Map<String, List<String>> checkEnv(RunScenarioRequest request, List<ApiScenarioWithBLOBs> apiScenarios) {
Map<String, List<String>> projectEnvMap = new HashMap<>();
if (StringUtils.equals(request.getRequestOriginator(), "TEST_PLAN")) {
this.checkPlanScenarioEnv(request);
} else if (StringUtils.isNotBlank(request.getRunMode()) &&
@ -306,6 +311,55 @@ public class ApiScenarioEnvService {
}
}
}
return projectEnvMap;
}
public Map<String, List<String>> selectApiScenarioEnv(List<ApiScenarioWithBLOBs> list) {
Map<String, List<String>> projectEnvMap = new LinkedHashMap<>();
for (int i = 0; i < list.size(); i++) {
try {
Map<String, String> map = new HashMap<>();
String environmentType = list.get(i).getEnvironmentType();
String environmentGroupId = list.get(i).getEnvironmentGroupId();
String env = list.get(i).getEnvironmentJson();
if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
// 环境属性为空 跳过
if (StringUtils.isBlank(env)) {
continue;
}
map = JSON.parseObject(env, Map.class);
} else if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) {
map = environmentGroupProjectService.getEnvMap(environmentGroupId);
}
Set<String> set = map.keySet();
HashMap<String, String> envMap = new HashMap<>(16);
// 项目为空 跳过
if (set.isEmpty()) {
continue;
}
for (String projectId : set) {
String envId = map.get(projectId);
envMap.put(projectId, envId);
}
for (Map.Entry<String, String> entry : envMap.entrySet()) {
String projectId = entry.getKey();
String envId = entry.getValue();
if (projectEnvMap.containsKey(projectId)) {
if (!projectEnvMap.get(projectId).contains(envId)) {
projectEnvMap.get(projectId).add(envId);
}
} else {
projectEnvMap.put(projectId, new ArrayList<>() {{
this.add(envId);
}});
}
}
} catch (Exception e) {
LogUtil.error("api scenario environment map incorrect parsing. api scenario id:" + list.get(i).getId());
}
}
return projectEnvMap;
}
public void setApiScenarioEnv(List<ApiScenarioDTO> list) {

View File

@ -2,6 +2,7 @@ package io.metersphere.api.exec.scenario;
import com.alibaba.fastjson.JSON;
import io.metersphere.api.dto.EnvironmentType;
import io.metersphere.api.dto.RunModeConfigWithEnvironmentDTO;
import io.metersphere.api.dto.RunModeDataDTO;
import io.metersphere.api.dto.automation.APIScenarioReportResult;
import io.metersphere.api.dto.automation.ExecuteType;
@ -9,6 +10,7 @@ import io.metersphere.api.dto.automation.RunScenarioRequest;
import io.metersphere.api.dto.definition.RunDefinitionRequest;
import io.metersphere.api.dto.definition.request.MsTestPlan;
import io.metersphere.api.dto.definition.request.ParameterConfig;
import io.metersphere.api.exec.api.ApiCaseExecuteService;
import io.metersphere.api.exec.queue.DBTestQueue;
import io.metersphere.api.exec.utils.GenerateHashTreeUtil;
import io.metersphere.api.jmeter.JMeterService;
@ -16,7 +18,10 @@ import io.metersphere.api.service.ApiExecutionQueueService;
import io.metersphere.api.service.ApiScenarioReportService;
import io.metersphere.api.service.ApiScenarioReportStructureService;
import io.metersphere.api.service.TcpApiParamService;
import io.metersphere.base.domain.*;
import io.metersphere.base.domain.ApiScenarioExample;
import io.metersphere.base.domain.ApiScenarioReportWithBLOBs;
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.base.domain.TestPlanApiScenario;
import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ApiScenarioReportMapper;
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
@ -26,10 +31,7 @@ import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.constants.ReportTypeConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.FileUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.commons.utils.*;
import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.JmeterRunRequestDTO;
import io.metersphere.dto.MsExecResponseDTO;
@ -86,6 +88,8 @@ public class ApiScenarioExecuteService {
@Resource
private TcpApiParamService tcpApiParamService;
@Resource
private ApiCaseExecuteService apiCaseExecuteService;
@Resource
protected JMeterService jMeterService;
public List<MsExecResponseDTO> run(RunScenarioRequest request) {
@ -154,10 +158,18 @@ public class ApiScenarioExecuteService {
LoggerUtil.info("Scenario run-执行脚本装载-初始化集成报告:" + serialReportId);
request.getConfig().setReportId(UUID.randomUUID().toString());
String reportScenarioIds = generateScenarioIds(scenarioIds);
if (request.getConfig() == null) {
request.setConfig(new RunModeConfigWithEnvironmentDTO());
}
if (MapUtils.isEmpty(request.getConfig().getEnvMap())) {
RunModeConfigWithEnvironmentDTO runModeConfig = new RunModeConfigWithEnvironmentDTO();
BeanUtils.copyBean(runModeConfig, request.getConfig());
Map<String, List<String>> projectEnvMap = apiScenarioEnvService.selectApiScenarioEnv(apiScenarios);
apiCaseExecuteService.setExecutionEnvironmen(runModeConfig, projectEnvMap);
request.setConfig(runModeConfig);
}
APIScenarioReportResult report = getApiScenarioReportResult(request, serialReportId, scenarioNames, reportScenarioIds);
report.setVersionId(apiScenarios.get(0).getVersionId());
apiScenarioReportMapper.insert(report);
responseDTOS.add(new MsExecResponseDTO(JSON.toJSONString(scenarioIds), serialReportId, request.getRunMode()));
@ -206,7 +218,7 @@ public class ApiScenarioExecuteService {
}
protected APIScenarioReportResult getApiScenarioReportResult(RunScenarioRequest request, String serialReportId,
StringBuilder scenarioNames, String reportScenarioIds) {
StringBuilder scenarioNames, String reportScenarioIds) {
APIScenarioReportResult report = apiScenarioReportService.init(request.getConfig().getReportId(), reportScenarioIds,
scenarioNames.toString(), request.getTriggerMode(), ExecuteType.Saved.name(), request.getProjectId(),
request.getReportUserID(), request.getConfig());
@ -303,7 +315,12 @@ public class ApiScenarioExecuteService {
executeQueue.put(report.getId(), runModeDataDTO);
scenarioNames.append(scenario.getName()).append(",");
if (request.getConfig() != null) {
report.setEnvConfig(JSON.toJSONString(request.getConfig()));
RunModeConfigWithEnvironmentDTO runModeConfig = new RunModeConfigWithEnvironmentDTO();
BeanUtils.copyBean(runModeConfig, request.getConfig());
if (MapUtils.isEmpty(runModeConfig.getEnvMap())) {
apiCaseExecuteService.setRunModeConfigEnvironment(runModeConfig, planEnvMap);
}
report.setEnvConfig(JSON.toJSONString(runModeConfig));
}
// 生成文档结构
if (!StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString())) {
@ -385,6 +402,12 @@ public class ApiScenarioExecuteService {
MSException.throwException(e.getMessage());
}
if (request.isSaved()) {
//记录环境
RunModeConfigDTO runModeCconfig = request.getConfig();
if (runModeCconfig == null) {
runModeCconfig = new RunModeConfigDTO();
runModeCconfig.setEnvMap(map);
}
APIScenarioReportResult report = apiScenarioReportService.init(request.getId(),
request.getScenarioId(),
request.getScenarioName(),
@ -392,7 +415,7 @@ public class ApiScenarioExecuteService {
request.getExecuteType(),
request.getProjectId(),
SessionUtils.getUserId(),
request.getConfig());
runModeCconfig);
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(request.getScenarioId());
String reportType = request.getConfig() != null ? request.getConfig().getReportType() : null;
if (scenario != null) {

View File

@ -43,7 +43,7 @@ public class ApiDefinitionExecResultUtil {
return apiResult;
}
public static ApiDefinitionExecResultWithBLOBs addResult(BatchRunDefinitionRequest request, TestPlanApiCase key, String status,
public static ApiDefinitionExecResultWithBLOBs addResult(BatchRunDefinitionRequest request, RunModeConfigDTO runModeConfigDTO, TestPlanApiCase key, String status,
Map<String, ApiTestCase> caseMap, String poolId) {
ApiDefinitionExecResultWithBLOBs apiResult = new ApiDefinitionExecResultWithBLOBs();
apiResult.setId(UUID.randomUUID().toString());
@ -75,7 +75,7 @@ public class ApiDefinitionExecResultUtil {
apiResult.setType(ApiRunMode.API_PLAN.name());
apiResult.setStatus(status);
apiResult.setContent(request.getPlanReportId());
apiResult.setEnvConfig(JSON.toJSONString(request.getConfig()));
apiResult.setEnvConfig(JSON.toJSONString(runModeConfigDTO));
return apiResult;
}

View File

@ -42,6 +42,7 @@ import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.dto.MsExecResponseDTO;
import io.metersphere.dto.ProjectConfig;
import io.metersphere.dto.RelationshipEdgeDTO;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.job.sechedule.SwaggerUrlImportJob;
import io.metersphere.log.utils.ReflexObjectUtil;
@ -58,6 +59,7 @@ import io.metersphere.track.service.TestCaseService;
import io.metersphere.track.service.TestPlanService;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.comparators.FixedOrderComparator;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
@ -152,6 +154,8 @@ public class ApiDefinitionService {
@Lazy
@Resource
private ApiModuleService apiModuleService;
@Resource
private ApiTestEnvironmentService apiTestEnvironmentService;
private ThreadLocal<Long> currentApiOrder = new ThreadLocal<>();
private ThreadLocal<Long> currentApiCaseOrder = new ThreadLocal<>();
@ -1225,6 +1229,13 @@ public class ApiDefinitionService {
result.setName(reportName);
result.setProjectId(request.getProjectId());
result.setTriggerMode(TriggerMode.MANUAL.name());
if (StringUtils.isNotEmpty(request.getEnvironmentId())) {
RunModeConfigDTO runModeConfigDTO = new RunModeConfigDTO();
runModeConfigDTO.setEnvMap(new HashMap<>() {{
this.put(request.getProjectId(), request.getEnvironmentId());
}});
result.setEnvConfig(JSONObject.toJSONString(runModeConfigDTO));
}
apiDefinitionExecResultMapper.insert(result);
}
if (request.isEditCaseRequest() && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree()) &&
@ -1278,10 +1289,31 @@ public class ApiDefinitionService {
}
APIReportResult reportResult = new APIReportResult();
reportResult.setStatus(result.getStatus());
reportResult.setContent(result.getContent());
if (StringUtils.isNotEmpty(result.getEnvConfig())) {
JSONObject content = JSONObject.parseObject(result.getContent());
content.put("envName", this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()));
reportResult.setContent(content.toJSONString());
} else {
reportResult.setContent(result.getContent());
}
return reportResult;
}
public String getEnvNameByEnvConfig(String projectId, String envConfig) {
String envName = null;
RunModeConfigDTO runModeConfigDTO = null;
try {
runModeConfigDTO = JSONObject.parseObject(envConfig, RunModeConfigDTO.class);
} catch (Exception e) {
LogUtil.error("解析" + envConfig + "为RunModeConfigDTO时失败", e);
}
if (StringUtils.isNotEmpty(projectId) && runModeConfigDTO != null && MapUtils.isNotEmpty(runModeConfigDTO.getEnvMap())) {
String envId = runModeConfigDTO.getEnvMap().get(projectId);
envName = apiTestEnvironmentService.selectNameById(envId);
}
return envName;
}
public APIReportResult getDbResult(String testId, String type) {
ApiDefinitionExecResultWithBLOBs result = extApiDefinitionExecResultMapper.selectMaxResultByResourceIdAndType(testId, type);
return buildAPIReportResult(result);

View File

@ -155,13 +155,14 @@ public class ApiScenarioReportService {
* @return
*/
public APIScenarioReportResult getApiIntegrated(String reportId) {
ApiDefinitionExecResult result = definitionExecResultMapper.selectByPrimaryKey(reportId);
ApiDefinitionExecResultWithBLOBs result = definitionExecResultMapper.selectByPrimaryKey(reportId);
if (result != null) {
APIScenarioReportResult reportResult = new APIScenarioReportResult();
BeanUtils.copyBean(reportResult, result);
reportResult.setReportVersion(2);
reportResult.setTestId(reportId);
ApiScenarioReportDTO dto = apiScenarioReportStructureService.apiIntegratedReport(reportId);
apiScenarioReportStructureService.initProjectEnvironmentByEnvConfig(dto, result.getEnvConfig());
reportResult.setContent(JSON.toJSONString(dto));
return reportResult;
}

View File

@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import io.metersphere.api.dto.ApiScenarioReportBaseInfoDTO;
import io.metersphere.api.dto.ApiScenarioReportDTO;
import io.metersphere.api.dto.RequestResultExpandDTO;
import io.metersphere.api.dto.StepTreeDTO;
import io.metersphere.api.dto.*;
import io.metersphere.api.exec.utils.ResultParseUtil;
import io.metersphere.api.service.vo.ApiDefinitionExecResultVo;
import io.metersphere.base.domain.*;
@ -22,10 +19,14 @@ import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.RequestResult;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.service.ProjectService;
import io.metersphere.utils.LoggerUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -50,6 +51,11 @@ public class ApiScenarioReportStructureService {
private ApiDefinitionExecResultMapper definitionExecResultMapper;
@Resource
private ExtApiScenarioReportResultMapper extApiScenarioReportResultMapper;
@Lazy
@Resource
private ProjectService projectService;
@Resource
private ApiTestEnvironmentService apiTestEnvironmentService;
private static final List<String> requests = Arrays.asList("HTTPSamplerProxy", "DubboSampler", "JDBCSampler", "TCPSampler", "JSR223Processor", "AbstractSampler");
private static final List<String> controls = Arrays.asList("Assertions", "IfController", "ConstantTimer");
@ -524,10 +530,73 @@ public class ApiScenarioReportStructureService {
dto.setActuator(report.getActuator());
dto.setName(report.getName());
dto.setEnvConfig(report.getEnvConfig());
this.initProjectEnvironmentByEnvConfig(dto, report.getEnvConfig());
return dto;
}
}
public void initProjectEnvironmentByEnvConfig(ApiScenarioReportDTO dto, String envConfig) {
if (StringUtils.isNotEmpty(envConfig)) {
//运行设置中选择的环境信息批量执行时在前台选择了执行信息
Map<String, String> envMapByRunConfig = null;
//执行时选择的环境信息 一般在集合报告中会记录
Map<String, List<String>> envMapByExecution = null;
try {
JSONObject jsonObject = JSONObject.parseObject(envConfig);
if (jsonObject.containsKey("executionEnvironmentMap")) {
RunModeConfigWithEnvironmentDTO configWithEnvironment = JSONObject.parseObject(envConfig, RunModeConfigWithEnvironmentDTO.class);
if (MapUtils.isNotEmpty(configWithEnvironment.getExecutionEnvironmentMap())) {
envMapByExecution = configWithEnvironment.getExecutionEnvironmentMap();
} else {
envMapByRunConfig = configWithEnvironment.getEnvMap();
}
} else {
RunModeConfigDTO config = JSONObject.parseObject(envConfig, RunModeConfigDTO.class);
envMapByRunConfig = config.getEnvMap();
}
} catch (Exception e) {
LogUtil.error("解析RunModeConfig失败!参数:" + envConfig, e);
}
LinkedHashMap<String, List<String>> projectEnvMap = new LinkedHashMap<>();
if (MapUtils.isNotEmpty(envMapByExecution)) {
for (Map.Entry<String, List<String>> entry : envMapByExecution.entrySet()) {
String projectId = entry.getKey();
List<String> envIdList = entry.getValue();
String projectName = projectService.selectNameById(projectId);
List<String> envNameList = apiTestEnvironmentService.selectNameByIds(envIdList);
if (CollectionUtils.isNotEmpty(envNameList) && StringUtils.isNotEmpty(projectName)) {
projectEnvMap.put(projectName, new ArrayList<>() {{
this.addAll(envNameList);
}});
}
}
if (MapUtils.isNotEmpty(projectEnvMap)) {
dto.setProjectEnvMap(projectEnvMap);
}
}
if (MapUtils.isNotEmpty(envMapByRunConfig)) {
for (Map.Entry<String, String> entry : envMapByRunConfig.entrySet()) {
String projectId = entry.getKey();
String envId = entry.getValue();
String projectName = projectService.selectNameById(projectId);
String envName = apiTestEnvironmentService.selectNameById(envId);
if (StringUtils.isNoneEmpty(projectName, envName)) {
projectEnvMap.put(projectName, new ArrayList<>() {{
this.add(envName);
}});
}
}
if (MapUtils.isNotEmpty(projectEnvMap)) {
dto.setProjectEnvMap(projectEnvMap);
}
}
}
}
private ApiScenarioReportDTO getReport(String reportId, boolean selectContent) {
List<ApiScenarioReportResultWithBLOBs> reportResults = null;
if (selectContent) {

View File

@ -10,6 +10,7 @@ import io.metersphere.base.domain.ApiTestEnvironmentExample;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.base.domain.Project;
import io.metersphere.base.mapper.ApiTestEnvironmentMapper;
import io.metersphere.base.mapper.ext.ExtApiTestEnvironmentMapper;
import io.metersphere.commons.constants.ProjectApplicationType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
@ -47,6 +48,8 @@ public class ApiTestEnvironmentService {
private EnvironmentGroupProjectService environmentGroupProjectService;
@Resource
private ProjectApplicationService projectApplicationService;
@Resource
private ExtApiTestEnvironmentMapper extApiTestEnvironmentMapper;
public List<ApiTestEnvironmentWithBLOBs> list(String projectId) {
ApiTestEnvironmentExample example = new ApiTestEnvironmentExample();
@ -102,7 +105,7 @@ public class ApiTestEnvironmentService {
checkEnvironmentExist(request);
FileUtils.createFiles(request.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl");
//检查Config判断isMock参数是否给True
request = this.updateConfig(request,false);
request = this.updateConfig(request, false);
request.setCreateTime(System.currentTimeMillis());
request.setUpdateTime(System.currentTimeMillis());
apiTestEnvironmentMapper.insert(request);
@ -110,29 +113,31 @@ public class ApiTestEnvironmentService {
}
private ApiTestEnvironmentDTO updateConfig(ApiTestEnvironmentDTO request, boolean isMock) {
if(StringUtils.isNotEmpty(request.getConfig())){
try{
if (StringUtils.isNotEmpty(request.getConfig())) {
try {
JSONObject configObj = JSONObject.parseObject(request.getConfig());
if(configObj.containsKey("httpConfig")){
if (configObj.containsKey("httpConfig")) {
JSONObject httpObj = configObj.getJSONObject("httpConfig");
httpObj.put("isMock",isMock);
httpObj.put("isMock", isMock);
}
request.setConfig(configObj.toJSONString());
}catch (Exception e){
} catch (Exception e) {
LogUtil.error("设置是否为mock环境出错!参数:" + request.getConfig(), e);
}
}
return request;
}
public void update(ApiTestEnvironmentDTO apiTestEnvironment,List<MultipartFile> sslFiles) {
public void update(ApiTestEnvironmentDTO apiTestEnvironment, List<MultipartFile> sslFiles) {
checkEnvironmentExist(apiTestEnvironment);
FileUtils.createFiles(apiTestEnvironment.getUploadIds(), sslFiles, FileUtils.BODY_FILE_DIR + "/ssl");
apiTestEnvironment.setUpdateTime(System.currentTimeMillis());
apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(apiTestEnvironment);
}
private void checkEnvironmentExist(ApiTestEnvironmentWithBLOBs environment) {
if (environment.getName() != null) {
if(StringUtils.isEmpty(environment.getProjectId())){
if (StringUtils.isEmpty(environment.getProjectId())) {
MSException.throwException(Translator.get("项目ID不能为空"));
}
ApiTestEnvironmentExample example = new ApiTestEnvironmentExample();
@ -177,16 +182,16 @@ public class ApiTestEnvironmentService {
String projectNumber = this.getSystemIdByProjectId(projectId);
if (list.isEmpty()) {
returnModel = this.genHttpApiTestEnvironmentByUrl(projectId,projectNumber, protocal, apiName, baseUrl);
returnModel = this.genHttpApiTestEnvironmentByUrl(projectId, projectNumber, protocal, apiName, baseUrl);
this.add(returnModel);
} else {
returnModel = list.get(0);
returnModel = this.checkMockEvnIsRightful(returnModel, protocal, projectId,projectNumber, apiName, baseUrl);
returnModel = this.checkMockEvnIsRightful(returnModel, protocal, projectId, projectNumber, apiName, baseUrl);
}
return returnModel;
}
private ApiTestEnvironmentWithBLOBs checkMockEvnIsRightful(ApiTestEnvironmentWithBLOBs returnModel, String protocal, String projectId,String projectNumber, String name, String url) {
private ApiTestEnvironmentWithBLOBs checkMockEvnIsRightful(ApiTestEnvironmentWithBLOBs returnModel, String protocal, String projectId, String projectNumber, String name, String url) {
boolean needUpdate = false;
ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class);
Project project = projectService.getProjectById(projectId);
@ -209,7 +214,7 @@ public class ApiTestEnvironmentService {
} else if (socket.startsWith("https://")) {
socket = socket.substring(8);
}
if (!obj.containsKey("socket") || !StringUtils.startsWith(String.valueOf(obj.get("socket")),socket)) {
if (!obj.containsKey("socket") || !StringUtils.startsWith(String.valueOf(obj.get("socket")), socket)) {
needUpdate = true;
break;
} else if (!obj.containsKey("protocol") || !StringUtils.equals(protocal, String.valueOf(obj.get("protocol")))) {
@ -218,7 +223,7 @@ public class ApiTestEnvironmentService {
}
String projectSocket = String.valueOf(obj.get("socket"));
if(!StringUtils.contains(projectSocket,"/mock/"+projectNumber)){
if (!StringUtils.contains(projectSocket, "/mock/" + projectNumber)) {
needUpdate = true;
break;
}
@ -229,22 +234,22 @@ public class ApiTestEnvironmentService {
}
ProjectConfig config = projectApplicationService.getSpecificTypeValue(project.getId(), ProjectApplicationType.MOCK_TCP_PORT.name());
Integer mockPortStr = config.getMockTcpPort();
if(mockPortStr != null && mockPortStr != 0){
if(configObj.containsKey("tcpConfig")){
if (mockPortStr != null && mockPortStr != 0) {
if (configObj.containsKey("tcpConfig")) {
JSONObject tcpConfigObj = configObj.getJSONObject("tcpConfig");
if(tcpConfigObj.containsKey("port")){
if(tcpConfigObj.getInteger("port").intValue() != mockPortStr){
if (tcpConfigObj.containsKey("port")) {
if (tcpConfigObj.getInteger("port").intValue() != mockPortStr) {
needUpdate = true;
}
}else {
} else {
needUpdate = true;
}
if(tcpConfigObj.containsKey("server")){
if(!StringUtils.equals(tcpConfigObj.getString("server"),url)){
if (tcpConfigObj.containsKey("server")) {
if (!StringUtils.equals(tcpConfigObj.getString("server"), url)) {
needUpdate = true;
}
}else {
} else {
needUpdate = true;
}
}
@ -256,23 +261,23 @@ public class ApiTestEnvironmentService {
}
if (needUpdate) {
String id = returnModel.getId();
returnModel = this.genHttpApiTestEnvironmentByUrl(id,project,projectNumber, protocal, name, url);
returnModel = this.genHttpApiTestEnvironmentByUrl(id, project, projectNumber, protocal, name, url);
apiTestEnvironmentMapper.updateByPrimaryKeyWithBLOBs(returnModel);
}
return returnModel;
}
private ApiTestEnvironmentWithBLOBs genHttpApiTestEnvironmentByUrl(String projectId,String projectNumber, String protocal, String name, String baseUrl) {
private ApiTestEnvironmentWithBLOBs genHttpApiTestEnvironmentByUrl(String projectId, String projectNumber, String protocal, String name, String baseUrl) {
ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class);
Project project = projectService.getProjectById(projectId);
if(project != null){
return this.genHttpApiTestEnvironmentByUrl(null,project,projectNumber, protocal, name, baseUrl);
if (project != null) {
return this.genHttpApiTestEnvironmentByUrl(null, project, projectNumber, protocal, name, baseUrl);
}
return null;
}
private ApiTestEnvironmentWithBLOBs genHttpApiTestEnvironmentByUrl(String envId,Project project,String projectNumber, String protocal, String name, String baseUrl) {
if(project == null){
private ApiTestEnvironmentWithBLOBs genHttpApiTestEnvironmentByUrl(String envId, Project project, String projectNumber, String protocal, String name, String baseUrl) {
if (project == null) {
return null;
}
String socket = "";
@ -284,7 +289,7 @@ public class ApiTestEnvironmentService {
}
socket = url;
String tcpSocket = socket;
if(StringUtils.isNotEmpty(tcpSocket) && tcpSocket.contains(":")){
if (StringUtils.isNotEmpty(tcpSocket) && tcpSocket.contains(":")) {
tcpSocket = socket.split(":")[0];
}
@ -318,7 +323,7 @@ public class ApiTestEnvironmentService {
JSONObject httpItem = new JSONObject();
httpItem.put("id", UUID.randomUUID().toString());
httpItem.put("type", "NONE");
httpItem.put("socket", socket+"/mock/"+projectNumber);
httpItem.put("socket", socket + "/mock/" + projectNumber);
httpItem.put("protocol", protocal);
JSONArray protocolVariablesArr = new JSONArray();
Map<String, Object> protocolMap = new HashMap<>();
@ -348,25 +353,25 @@ public class ApiTestEnvironmentService {
tcpConfigObj.put("reUseConnection", false);
tcpConfigObj.put("nodelay", false);
tcpConfigObj.put("closeConnection", false);
if(project != null){
if (project != null) {
ProjectConfig config = projectApplicationService.getSpecificTypeValue(project.getId(), ProjectApplicationType.MOCK_TCP_PORT.name());
Integer mockPort = config.getMockTcpPort();
if(mockPort != null && mockPort != 0){
if (mockPort != null && mockPort != 0) {
tcpConfigObj.put("server", tcpSocket);
tcpConfigObj.put("port", mockPort);
}
}
ApiTestEnvironmentWithBLOBs blobs = null;
if(StringUtils.isNotEmpty(envId)) {
if (StringUtils.isNotEmpty(envId)) {
blobs = this.get(envId);
}
if(blobs != null && StringUtils.isNotEmpty(blobs.getConfig())){
if (blobs != null && StringUtils.isNotEmpty(blobs.getConfig())) {
JSONObject object = JSONObject.parseObject(blobs.getConfig());
object.put("httpConfig", httpConfig);
object.put("tcpConfig", tcpConfigObj);
blobs.setConfig(object.toString());
}else {
} else {
blobs = new ApiTestEnvironmentWithBLOBs();
JSONObject commonConfigObj = new JSONObject();
JSONArray commonVariablesArr = new JSONArray();
@ -403,18 +408,18 @@ public class ApiTestEnvironmentService {
protocal = "https";
}
String projectNumber = this.getSystemIdByProjectId(model.getProjectId());
model = this.checkMockEvnIsRightful(model, protocal, model.getProjectId(),projectNumber, model.getName(), baseUrl);
model = this.checkMockEvnIsRightful(model, protocal, model.getProjectId(), projectNumber, model.getName(), baseUrl);
}
}
}
private String getSystemIdByProjectId(String projectId){
private String getSystemIdByProjectId(String projectId) {
ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class);
Project project = projectService.getProjectById(projectId);
if(project != null){
if (project != null) {
project = projectService.checkSystemId(project);
return projectService.getSystemIdByProjectId(projectId);
}else {
return projectService.getSystemIdByProjectId(projectId);
} else {
return "";
}
}
@ -436,28 +441,40 @@ public class ApiTestEnvironmentService {
try {
JSONObject configObj = JSONObject.parseObject(mockEnv.getConfig());
if(configObj.containsKey("tcpConfig")){
if (configObj.containsKey("tcpConfig")) {
JSONObject tcpConfigObj = configObj.getJSONObject("tcpConfig");
int tcpPort = 0;
if(tcpConfigObj.containsKey("port")){
if (tcpConfigObj.containsKey("port")) {
tcpPort = tcpConfigObj.getInteger("port").intValue();
if(tcpPort == 0 || !TCPPool.isTcpOpen(tcpPort)){
if (tcpPort == 0 || !TCPPool.isTcpOpen(tcpPort)) {
return returnStr;
}
}else {
} else {
return returnStr;
}
if(tcpConfigObj.containsKey("server")){
if (tcpConfigObj.containsKey("server")) {
String server = tcpConfigObj.getString("server");
returnStr = server +":"+ tcpPort;
}else {
returnStr = server + ":" + tcpPort;
} else {
return returnStr;
}
}
}catch (Exception e){
} catch (Exception e) {
LogUtil.error(e);
}
}
return returnStr;
}
public List<String> selectNameByIds(Collection<String> envIds) {
if (CollectionUtils.isNotEmpty(envIds)) {
return extApiTestEnvironmentMapper.selectNameByIds(envIds);
} else {
return new ArrayList<>(0);
}
}
public String selectNameById(String id) {
return extApiTestEnvironmentMapper.selectNameById(id);
}
}

View File

@ -37,5 +37,7 @@ public class TestPlanReport implements Serializable {
private Boolean isNew;
private String runInfo;
private static final long serialVersionUID = 1L;
}

View File

@ -51,5 +51,7 @@ public class TestPlanReportContentWithBLOBs extends TestPlanReportContent implem
private String unExecuteScenarios;
private String apiBaseCount;
private static final long serialVersionUID = 1L;
}

View File

@ -33,6 +33,7 @@
<result column="error_report_scenarios" jdbcType="LONGVARCHAR" property="errorReportScenarios" />
<result column="un_execute_cases" jdbcType="LONGVARCHAR" property="unExecuteCases" />
<result column="un_execute_scenarios" jdbcType="LONGVARCHAR" property="unExecuteScenarios" />
<result column="api_base_count" jdbcType="LONGVARCHAR" property="apiBaseCount" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -101,7 +102,7 @@
issue_list, api_all_cases, api_failure_cases, scenario_all_cases, scenario_failure_cases,
load_all_Cases, load_failure_cases, plan_scenario_report_struct, plan_api_case_report_struct,
plan_load_case_report_struct, error_report_cases, error_report_scenarios, un_execute_cases,
un_execute_scenarios
un_execute_scenarios, api_base_count
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanReportContentExample" resultMap="ResultMapWithBLOBs">
select
@ -163,7 +164,8 @@
plan_scenario_report_struct, plan_api_case_report_struct,
plan_load_case_report_struct, error_report_cases,
error_report_scenarios, un_execute_cases,
un_execute_scenarios)
un_execute_scenarios, api_base_count
)
values (#{id,jdbcType=VARCHAR}, #{testPlanReportId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT},
#{caseCount,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{executeRate,jdbcType=DOUBLE},
#{passRate,jdbcType=DOUBLE}, #{isThirdPartIssue,jdbcType=BIT}, #{config,jdbcType=LONGVARCHAR},
@ -175,7 +177,8 @@
#{planScenarioReportStruct,jdbcType=LONGVARCHAR}, #{planApiCaseReportStruct,jdbcType=LONGVARCHAR},
#{planLoadCaseReportStruct,jdbcType=LONGVARCHAR}, #{errorReportCases,jdbcType=LONGVARCHAR},
#{errorReportScenarios,jdbcType=LONGVARCHAR}, #{unExecuteCases,jdbcType=LONGVARCHAR},
#{unExecuteScenarios,jdbcType=LONGVARCHAR})
#{unExecuteScenarios,jdbcType=LONGVARCHAR}, #{apiBaseCount,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanReportContentWithBLOBs">
insert into test_plan_report_content
@ -267,6 +270,9 @@
<if test="unExecuteScenarios != null">
un_execute_scenarios,
</if>
<if test="apiBaseCount != null">
api_base_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -356,6 +362,9 @@
<if test="unExecuteScenarios != null">
#{unExecuteScenarios,jdbcType=LONGVARCHAR},
</if>
<if test="apiBaseCount != null">
#{apiBaseCount,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanReportContentExample" resultType="java.lang.Long">
@ -454,6 +463,9 @@
<if test="record.unExecuteScenarios != null">
un_execute_scenarios = #{record.unExecuteScenarios,jdbcType=LONGVARCHAR},
</if>
<if test="record.apiBaseCount != null">
api_base_count = #{record.apiBaseCount,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -489,7 +501,8 @@
error_report_cases = #{record.errorReportCases,jdbcType=LONGVARCHAR},
error_report_scenarios = #{record.errorReportScenarios,jdbcType=LONGVARCHAR},
un_execute_cases = #{record.unExecuteCases,jdbcType=LONGVARCHAR},
un_execute_scenarios = #{record.unExecuteScenarios,jdbcType=LONGVARCHAR}
un_execute_scenarios = #{record.unExecuteScenarios,jdbcType=LONGVARCHAR},
api_base_count = #{record.apiBaseCount,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -595,6 +608,9 @@
<if test="unExecuteScenarios != null">
un_execute_scenarios = #{unExecuteScenarios,jdbcType=LONGVARCHAR},
</if>
<if test="apiBaseCount != null">
api_base_count = #{apiBaseCount,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -627,7 +643,8 @@
error_report_cases = #{errorReportCases,jdbcType=LONGVARCHAR},
error_report_scenarios = #{errorReportScenarios,jdbcType=LONGVARCHAR},
un_execute_cases = #{unExecuteCases,jdbcType=LONGVARCHAR},
un_execute_scenarios = #{unExecuteScenarios,jdbcType=LONGVARCHAR}
un_execute_scenarios = #{unExecuteScenarios,jdbcType=LONGVARCHAR},
api_base_count = #{apiBaseCount,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanReportContent">

View File

@ -1,13 +1,8 @@
package io.metersphere.base.mapper;
import io.metersphere.api.dto.definition.ParamsDTO;
import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.base.domain.TestPlanReportExample;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
public interface TestPlanReportMapper {
@ -21,15 +16,21 @@ public interface TestPlanReportMapper {
int insertSelective(TestPlanReport record);
List<TestPlanReport> selectByExampleWithBLOBs(TestPlanReportExample example);
List<TestPlanReport> selectByExample(TestPlanReportExample example);
TestPlanReport selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestPlanReport record, @Param("example") TestPlanReportExample example);
int updateByExampleWithBLOBs(@Param("record") TestPlanReport record, @Param("example") TestPlanReportExample example);
int updateByExample(@Param("record") TestPlanReport record, @Param("example") TestPlanReportExample example);
int updateByPrimaryKeySelective(TestPlanReport record);
int updateByPrimaryKeyWithBLOBs(TestPlanReport record);
int updateByPrimaryKey(TestPlanReport record);
}

View File

@ -19,6 +19,9 @@
<result column="components" jdbcType="VARCHAR" property="components" />
<result column="is_new" jdbcType="BIT" property="isNew" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.TestPlanReport">
<result column="run_info" jdbcType="LONGVARCHAR" property="runInfo" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
@ -82,6 +85,25 @@
start_time, end_time, is_api_case_executing, is_scenario_executing, is_performance_executing,
principal, components, is_new
</sql>
<sql id="Blob_Column_List">
run_info
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanReportExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from test_plan_report
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestPlanReportExample" resultMap="BaseResultMap">
select
<if test="distinct">
@ -96,9 +118,11 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from test_plan_report
where id = #{id,jdbcType=VARCHAR}
</select>
@ -118,13 +142,13 @@
trigger_mode, creator, start_time,
end_time, is_api_case_executing, is_scenario_executing,
is_performance_executing, principal, components,
is_new)
is_new, run_info)
values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{triggerMode,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT},
#{endTime,jdbcType=BIGINT}, #{isApiCaseExecuting,jdbcType=BIT}, #{isScenarioExecuting,jdbcType=BIT},
#{isPerformanceExecuting,jdbcType=BIT}, #{principal,jdbcType=VARCHAR}, #{components,jdbcType=VARCHAR},
#{isNew,jdbcType=BIT})
#{isNew,jdbcType=BIT}, #{runInfo,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestPlanReport">
insert into test_plan_report
@ -177,6 +201,9 @@
<if test="isNew != null">
is_new,
</if>
<if test="runInfo != null">
run_info,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -227,6 +254,9 @@
<if test="isNew != null">
#{isNew,jdbcType=BIT},
</if>
<if test="runInfo != null">
#{runInfo,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestPlanReportExample" resultType="java.lang.Long">
@ -235,7 +265,6 @@
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_plan_report
<set>
@ -287,11 +316,37 @@
<if test="record.isNew != null">
is_new = #{record.isNew,jdbcType=BIT},
</if>
<if test="record.runInfo != null">
run_info = #{record.runInfo,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update test_plan_report
set id = #{record.id,jdbcType=VARCHAR},
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR},
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
creator = #{record.creator,jdbcType=VARCHAR},
start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT},
is_api_case_executing = #{record.isApiCaseExecuting,jdbcType=BIT},
is_scenario_executing = #{record.isScenarioExecuting,jdbcType=BIT},
is_performance_executing = #{record.isPerformanceExecuting,jdbcType=BIT},
principal = #{record.principal,jdbcType=VARCHAR},
components = #{record.components,jdbcType=VARCHAR},
is_new = #{record.isNew,jdbcType=BIT},
run_info = #{record.runInfo,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_plan_report
set id = #{record.id,jdbcType=VARCHAR},
@ -362,9 +417,32 @@
<if test="isNew != null">
is_new = #{isNew,jdbcType=BIT},
</if>
<if test="runInfo != null">
run_info = #{runInfo,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.TestPlanReport">
update test_plan_report
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
`name` = #{name,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR},
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
creator = #{creator,jdbcType=VARCHAR},
start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT},
is_api_case_executing = #{isApiCaseExecuting,jdbcType=BIT},
is_scenario_executing = #{isScenarioExecuting,jdbcType=BIT},
is_performance_executing = #{isPerformanceExecuting,jdbcType=BIT},
principal = #{principal,jdbcType=VARCHAR},
components = #{components,jdbcType=VARCHAR},
is_new = #{isNew,jdbcType=BIT},
run_info = #{runInfo,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestPlanReport">
update test_plan_report
set test_plan_id = #{testPlanId,jdbcType=VARCHAR},

View File

@ -0,0 +1,12 @@
package io.metersphere.base.mapper.ext;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface ExtApiTestEnvironmentMapper {
List<String> selectNameByIds(@Param("ids") Collection<String> envIdSet);
String selectNameById(String id);
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.metersphere.base.mapper.ext.ExtApiTestEnvironmentMapper">
<resultMap id="BaseResultMap" type="io.metersphere.api.dto.APITestResult"
extends="io.metersphere.base.mapper.ApiTestMapper.BaseResultMap">
<result column="project_name" property="projectName"/>
<result column="user_name" property="userName"/>
</resultMap>
<select id="selectNameByIds" resultType="java.lang.String">
SELECT name
FROM api_test_environment
<where>
id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</where>
</select>
<select id="selectNameById" resultType="java.lang.String">
SELECT name
FROM api_test_environment
WHERE id = #{0}
</select>
</mapper>

View File

@ -6,6 +6,7 @@ import io.metersphere.api.dto.definition.TestPlanApiCaseDTO;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.base.domain.TestPlanApiCase;
import io.metersphere.track.dto.PlanReportCaseDTO;
import io.metersphere.track.dto.testplan.TestPlanApiCaseInfoDTO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -30,7 +31,7 @@ public interface ExtTestPlanApiCaseMapper {
String getApiTestCaseIdById(String testPlanApiCaseId);
List<TestPlanApiCase> selectLegalDataByTestPlanId(String planId);
List<TestPlanApiCaseInfoDTO> selectLegalDataByTestPlanId(String planId);
List<PlanReportCaseDTO> selectForPlanReport(String planId);

View File

@ -3,360 +3,386 @@
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper">
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiCase">
INSERT INTO test_plan_api_case(id, test_plan_id, api_case_id, environment_id, create_time, update_time, create_user, `order`)
SELECT #{request.id}, #{request.testPlanId}, #{request.apiCaseId}, #{request.environmentId}, #{request.createTime}, #{request.updateTime}, #{request.createUser}, #{request.order}
FROM DUAL
WHERE NOT EXISTS(
SELECT id FROM
test_plan_api_case
WHERE test_plan_id = #{request.testPlanId} and api_case_id = #{request.apiCaseId}
)
</insert>
<select id="getApiTestCaseById" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
SELECT t.* FROM api_test_case t
INNER JOIN test_plan_api_case tpac ON t.id = tpac.api_case_id
WHERE tpac.id = #{0}
</select>
<select id="getApiTestCaseIdById" resultType="java.lang.String">
SELECT api_case_id FROM test_plan_api_case t WHERE id = #{0}
</select>
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.base.domain.TestPlanApiCase">
SELECT t.* FROM test_plan_api_case t WHERE t.test_plan_id = #{0}
AND t.api_case_id IN (
SELECT id FROM api_test_case WHERE status IS NULL OR status != 'Trash'
)
ORDER BY `order` DESC
</select>
<select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO">
select
t.id,
t.environment_id,
(
SELECT
NAME
FROM
api_test_environment
WHERE
id = t.environment_id
) AS environment_name,
t.create_time,
t.update_time,
c.id AS case_id,
c.project_id,
c.name,
c.api_definition_id,
c.priority,
c.description,
c.create_user_id,
c.update_user_id,
c.num,
c.tags,
c.create_user_id as create_user,
a.module_id,
a.path,
a.protocol,
t.status execResult,
a.user_id,
a.version_id versionId
from
test_plan_api_case t
inner join
api_test_case c
on t.api_case_id = c.id
<if test="request.planId != null and request.planId!=''">
and t.test_plan_id = #{request.planId}
</if>
inner join
api_definition a
on
c.api_definition_id = a.id
where 1
<if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol}
</if>
<choose>
<when test="request.status == 'Trash'">
and c.status = 'Trash'
</when>
<when test="request.status == null">
and (c.status IS NULL or c.status != 'Trash')
</when>
<when test="request.status == ''">
and (c.status IS NULL or c.status != 'Trash')
</when>
<when test="request.status == 'running'">
and t.status IS NULL
</when>
<otherwise>
and t.status = #{request.status}
</otherwise>
</choose>
<if test="request.ids != null and request.ids.size() > 0">
<if test="request.projectId != null and request.projectId!=''">
and a.projectId = #{request.projectId}
</if>
and t.id in
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
#{caseId}
</foreach>
</if>
<if test="request.name != null and request.name!=''">
and (c.name like CONCAT('%', #{request.name},'%')
or c.tags like CONCAT('%', #{request.name},'%')
or c.num like CONCAT('%', #{request.name},'%')
)
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and a.module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'priority'">
and c.priority in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
<when test="key == 'user_id'">
and c.create_user_id in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
<when test="key == 'version_id'">
and a.version_id in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
<when test="key == 'exec_result'">
and t.status in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
</choose>
<insert id="insertIfNotExists" parameterType="io.metersphere.base.domain.TestPlanApiCase">
INSERT INTO test_plan_api_case(id, test_plan_id, api_case_id, environment_id, create_time, update_time,
create_user, `order`)
SELECT #{request.id},
#{request.testPlanId},
#{request.apiCaseId},
#{request.environmentId},
#{request.createTime},
#{request.updateTime},
#{request.createUser},
#{request.order}
FROM DUAL
WHERE NOT EXISTS(
SELECT id
FROM test_plan_api_case
WHERE test_plan_id = #{request.testPlanId}
and api_case_id = #{request.apiCaseId}
)
</insert>
<select id="getApiTestCaseById" resultType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
SELECT t.*
FROM api_test_case t
INNER JOIN test_plan_api_case tpac ON t.id = tpac.api_case_id
WHERE tpac.id = #{0}
</select>
<select id="getApiTestCaseIdById" resultType="java.lang.String">
SELECT api_case_id
FROM test_plan_api_case t
WHERE id = #{0}
</select>
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.track.dto.testplan.TestPlanApiCaseInfoDTO">
SELECT a.project_id, t.*
FROM test_plan_api_case t
INNER JOIN api_test_case a ON t.api_case_id = a.id
WHERE t.test_plan_id = #{0}
AND (a.status IS NULL OR a.status != 'Trash')
ORDER BY t.`order` DESC
</select>
<select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO">
select
t.id,
t.environment_id,
(
SELECT
NAME
FROM
api_test_environment
WHERE
id = t.environment_id
) AS environment_name,
t.create_time,
t.update_time,
c.id AS case_id,
c.project_id,
c.name,
c.api_definition_id,
c.priority,
c.description,
c.create_user_id,
c.update_user_id,
c.num,
c.tags,
c.create_user_id as create_user,
a.module_id,
a.path,
a.protocol,
t.status execResult,
a.user_id,
a.version_id versionId
from
test_plan_api_case t
inner join
api_test_case c
on t.api_case_id = c.id
<if test="request.planId != null and request.planId!=''">
and t.test_plan_id = #{request.planId}
</if>
</foreach>
</if>
<include refid="queryVersionCondition">
<property name="versionTable" value="a"/>
</include>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
<choose>
<when test="order.name == 'update_time' or order.name == 'order'">
t.${order.name} ${order.type}
</when>
<when test="order.name == 'create_user'">
create_user_id ${order.type}
</when>
<otherwise>
${order.name} ${order.type}
</otherwise>
</choose>
</foreach>
</if>
</select>
<select id="selectIds" resultType="java.lang.String">
select
t.id
from
test_plan_api_case t
inner join
api_test_case c
on t.api_case_id = c.id
<if test="request.planId != null and request.planId!=''">
and t.test_plan_id = #{request.planId}
</if>
inner join
api_definition a
on
c.api_definition_id = a.id
<if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol}
</if>
<choose>
<when test="request.status == 'Trash'">
and a.status = 'Trash'
</when>
<when test="request.status == null">
and a.status != 'Trash'
</when>
<when test="request.status == ''">
and a.status != 'Trash'
</when>
<when test="request.status == 'running'">
and t.status IS NULL
</when>
<otherwise>
and t.status = #{request.status}
</otherwise>
</choose>
where 1
<if test="request.ids != null and request.ids.size() > 0">
<if test="request.projectId != null and request.projectId!=''">
and
</if>
t.id in
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
#{caseId}
</foreach>
</if>
<if test="request.name != null and request.name!=''">
and (c.name like CONCAT('%', #{request.name},'%') or c.tags like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and a.module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'priority'">
and c.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key == 'user_id'">
and c.create_user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
inner join
api_definition a
on
c.api_definition_id = a.id
where 1
<if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol}
</if>
</foreach>
</if>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
<choose>
<when test="order.name == 'update_time' or order.name == 'order'" >
t.${order.name} ${order.type}
</when>
<when test="order.name == 'create_user'">
create_user_id ${order.type}
</when>
<otherwise>
c.${order.name} ${order.type}
</otherwise>
<when test="request.status == 'Trash'">
and c.status = 'Trash'
</when>
<when test="request.status == null">
and (c.status IS NULL or c.status != 'Trash')
</when>
<when test="request.status == ''">
and (c.status IS NULL or c.status != 'Trash')
</when>
<when test="request.status == 'running'">
and t.status IS NULL
</when>
<otherwise>
and t.status = #{request.status}
</otherwise>
</choose>
</foreach>
</if>
</select>
<select id="getExecResultByPlanId" resultType="java.lang.String">
select status
from
test_plan_api_case
where test_plan_id = #{planId}
AND api_case_id in (SELECT id FROM api_test_case WHERE (`status` is null or `status` != 'Trash'))
</select>
<if test="request.ids != null and request.ids.size() > 0">
<if test="request.projectId != null and request.projectId!=''">
and a.projectId = #{request.projectId}
</if>
and t.id in
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
#{caseId}
</foreach>
</if>
<if test="request.name != null and request.name!=''">
and (c.name like CONCAT('%', #{request.name},'%')
or c.tags like CONCAT('%', #{request.name},'%')
or c.num like CONCAT('%', #{request.name},'%')
)
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and a.module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'priority'">
and c.priority in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
<when test="key == 'user_id'">
and c.create_user_id in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
<when test="key == 'version_id'">
and a.version_id in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
<when test="key == 'exec_result'">
and t.status in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
</when>
</choose>
</if>
</foreach>
</if>
<include refid="queryVersionCondition">
<property name="versionTable" value="a"/>
</include>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
<choose>
<when test="order.name == 'update_time' or order.name == 'order'">
t.${order.name} ${order.type}
</when>
<when test="order.name == 'create_user'">
create_user_id ${order.type}
</when>
<otherwise>
${order.name} ${order.type}
</otherwise>
</choose>
</foreach>
</if>
<select id="getIdsByPlanId" resultType="java.lang.String">
select id
from test_plan_api_case
where id = #{planId}
</select>
</select>
<select id="selectIds" resultType="java.lang.String">
select
t.id
from
test_plan_api_case t
inner join
api_test_case c
on t.api_case_id = c.id
<if test="request.planId != null and request.planId!=''">
and t.test_plan_id = #{request.planId}
</if>
inner join
api_definition a
on
c.api_definition_id = a.id
<if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol}
</if>
<choose>
<when test="request.status == 'Trash'">
and a.status = 'Trash'
</when>
<when test="request.status == null">
and a.status != 'Trash'
</when>
<when test="request.status == ''">
and a.status != 'Trash'
</when>
<when test="request.status == 'running'">
and t.status IS NULL
</when>
<otherwise>
and t.status = #{request.status}
</otherwise>
</choose>
where 1
<if test="request.ids != null and request.ids.size() > 0">
<if test="request.projectId != null and request.projectId!=''">
and
</if>
t.id in
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
#{caseId}
</foreach>
</if>
<if test="request.name != null and request.name!=''">
and (c.name like CONCAT('%', #{request.name},'%') or c.tags like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and a.module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'priority'">
and c.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key == 'user_id'">
and c.create_user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
<choose>
<when test="order.name == 'update_time' or order.name == 'order'">
t.${order.name} ${order.type}
</when>
<when test="order.name == 'create_user'">
create_user_id ${order.type}
</when>
<otherwise>
c.${order.name} ${order.type}
</otherwise>
</choose>
</foreach>
</if>
</select>
<select id="getExecResultByPlanId" resultType="java.lang.String">
select status
from test_plan_api_case
where test_plan_id = #{planId}
AND api_case_id in (SELECT id FROM api_test_case WHERE (`status` is null or `status` != 'Trash'))
</select>
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
select t.id
from test_plan_api_case t
inner join api_test_case c
on c.id = t.api_case_id
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
and c.project_id not in
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
#{projectId}
</foreach>
</if>
where t.test_plan_id = #{planId}
</select>
<select id="getStatusByTestPlanId" resultType="java.lang.String">
SELECT `status` FROM test_plan_api_case WHERE test_plan_id = #{0}
</select>
<select id="getIdsByPlanId" resultType="java.lang.String">
select id
from test_plan_api_case
where id = #{planId}
</select>
<select id="getNotRelevanceCaseIds" resultType="java.lang.String">
select t.id
from test_plan_api_case t
inner join api_test_case c
on c.id = t.api_case_id
<if test="relevanceProjectIds != null and relevanceProjectIds.size() > 0">
and c.project_id not in
<foreach collection="relevanceProjectIds" item="projectId" separator="," open="(" close=")">
#{projectId}
</foreach>
</if>
where t.test_plan_id = #{planId}
</select>
<select id="getStatusByTestPlanId" resultType="java.lang.String">
SELECT `status`
FROM test_plan_api_case
WHERE test_plan_id = #{0}
</select>
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
select id,status from test_plan_api_case where test_plan_id = #{planId} and api_case_id IN (
SELECT id FROM api_test_case where status is null or status != 'Trash'
)
select id, status
from test_plan_api_case
where test_plan_id = #{planId}
and api_case_id IN (
SELECT id
FROM api_test_case
where status is null
or status
!= 'Trash'
)
</select>
<select id="getFailureList" resultType="io.metersphere.api.dto.automation.TestPlanFailureApiDTO">
select
select
t.id,
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.create_user_id,
c.num,c.create_user_id AS create_user,
t.status execResult
from
from
test_plan_api_case t
inner join
inner join
api_test_case c
on t.api_case_id = c.id
and t.test_plan_id = #{planId}
and t.test_plan_id = #{planId}
<if test="status == 'unExecute'">
and (t.status in ('Stop','unExecute') or t.status IS NULL)
</if>
<if test="status != null and status != 'unExecute'">
and t.status = #{status}
</if>
and (c.status != 'Trash' or c.status is null)
where t.test_plan_id = #{planId} ORDER BY t.order DESC
<if test="status != null and status != 'unExecute'">
and t.status = #{status}
</if>
and (c.status != 'Trash' or c.status is null)
where t.test_plan_id = #{planId} ORDER BY t.order DESC
</select>
<select id="getFailureListByIds" resultType="io.metersphere.api.dto.automation.TestPlanFailureApiDTO">
select
t.id,
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.create_user_id,
c.num,t.create_user,
t.status execResult
from
test_plan_api_case t
inner join
api_test_case c
on t.api_case_id = c.id
<if test="status != null">
and t.status = 'error'
</if>
where t.id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
ORDER BY t.order DESC
</select>
<select id="getFailureListByIds" resultType="io.metersphere.api.dto.automation.TestPlanFailureApiDTO">
select
t.id,
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.create_user_id,
c.num,t.create_user,
t.status execResult
from
test_plan_api_case t
inner join
api_test_case c
on t.api_case_id = c.id
<if test="status != null">
and t.status = 'error'
</if>
where t.id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
ORDER BY t.order DESC
</select>
<select id="selectPlanIds" resultType="java.lang.String">
select DISTINCT test_plan_id from test_plan_api_case;
</select>
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
select id from test_plan_api_case where test_plan_id = #{planId} order by update_time ASC;
</select>
<select id="selectPlanIds" resultType="java.lang.String">
select DISTINCT test_plan_id
from test_plan_api_case;
</select>
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
select id
from test_plan_api_case
where test_plan_id = #{planId}
order by update_time ASC;
</select>
<select id="getLastOrder" resultType="java.lang.Long">
select `order` from test_plan_api_case where test_plan_id = #{planId}
<if test="baseOrder != null">
and `order` &gt; #{baseOrder}
</if>
order by `order` desc limit 1;
</select>
<select id="getLastOrder" resultType="java.lang.Long">
select `order` from test_plan_api_case where test_plan_id = #{planId}
<if test="baseOrder != null">
and `order` &gt; #{baseOrder}
</if>
order by `order` desc limit 1;
</select>
<select id="getPreOrder" resultType="java.lang.Long">
select `order` from test_plan_api_case where test_plan_id = #{planId}
<if test="baseOrder != null">
and `order` &lt; #{baseOrder}
</if>
order by `order` desc limit 1;
</select>
<select id="getPreOrder" resultType="java.lang.Long">
select `order` from test_plan_api_case where test_plan_id = #{planId}
<if test="baseOrder != null">
and `order` &lt; #{baseOrder}
</if>
order by `order` desc limit 1;
</select>
<sql id="queryVersionCondition">
<if test="request.versionId != null">
and ${versionTable}.version_id = #{request.versionId}
</if>
<if test="request.refId != null">
and ${versionTable}.ref_id = #{request.refId}
</if>
</sql>
<sql id="queryVersionCondition">
<if test="request.versionId != null">
and ${versionTable}.version_id = #{request.versionId}
</if>
<if test="request.refId != null">
and ${versionTable}.ref_id = #{request.refId}
</if>
</sql>
</mapper>

View File

@ -5,6 +5,7 @@ import io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO;
import io.metersphere.api.dto.automation.TestPlanScenarioRequest;
import io.metersphere.base.domain.TestPlanApiScenario;
import io.metersphere.track.dto.PlanReportCaseDTO;
import io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -25,7 +26,7 @@ public interface ExtTestPlanScenarioCaseMapper {
List<TestPlanApiScenario> selectByIds(@Param("ids")String ids ,@Param("oderId")String oderId );
List<TestPlanApiScenario> selectLegalDataByTestPlanId(String planId);
List<TestPlanApiScenarioInfoDTO> selectLegalDataByTestPlanId(String planId);
List<PlanReportCaseDTO> selectForPlanReport(String planId);

View File

@ -15,12 +15,12 @@
)
</insert>
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.base.domain.TestPlanApiScenario">
SELECT t.* FROM test_plan_api_scenario t WHERE t.test_plan_id = #{0}
AND t.api_scenario_id IN (
SELECT id FROM api_scenario WHERE status IS NULL OR status != 'Trash'
)
ORDER BY `order` DESC
<select id="selectLegalDataByTestPlanId" resultType="io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO">
SELECT tpas.id, tpas.api_scenario_id,tpas.environment,apis.project_id FROM
test_plan_api_scenario tpas INNER JOIN api_scenario apis ON tpas.api_scenario_id = apis.id
WHERE (apis.`status` IS NULL OR apis.`status` != 'Trash')
AND tpas.test_plan_id = #{0}
ORDER BY tpas.`order` DESC;
</select>
<select id="list" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO">

View File

@ -178,7 +178,7 @@ public class EnvironmentGroupService {
}
if (environmentGroupMapper.countByExample(environmentGroupExample) > 0) {
MSException.throwException(Translator.get("environment_group_name")+request.getName()+Translator.get("environment_group_exist"));
MSException.throwException(Translator.get("environment_group_name") + request.getName() + Translator.get("environment_group_exist"));
}
}
@ -307,4 +307,8 @@ public class EnvironmentGroupService {
}
return result;
}
public EnvironmentGroup selectById(String id) {
return environmentGroupMapper.selectByPrimaryKey(id);
}
}

View File

@ -1080,4 +1080,13 @@ public class ProjectService {
}
}
}
public String selectNameById(String projectId) {
Project project = projectMapper.selectByPrimaryKey(projectId);
if (project == null) {
return null;
} else {
return project.getName();
}
}
}

View File

@ -76,7 +76,7 @@ public class TestPlanReportController {
String userId = SessionUtils.getUser().getId();
String reportId = UUID.randomUUID().toString();
TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest(reportId, planId, userId, triggerMode);
TestPlanScheduleReportInfoDTO report = testPlanReportService.genTestPlanReport(saveRequest);
TestPlanScheduleReportInfoDTO report = testPlanReportService.genTestPlanReport(saveRequest,null);
testPlanReportService.genTestPlanReportContent(report);
testPlanReportService.countReportByTestPlanReportId(report.getTestPlanReport().getId(), null, triggerMode);
return "success";

View File

@ -8,6 +8,7 @@ import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@ -20,6 +21,16 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent {
private String summary;
private String config;
/**
* 运行环境信息
* runMode:运行模式 并行/串行
* envGroupName 用户组名称
* projectEnvMap: <项目,运行环境>
*/
private String runMode;
private String envGroupName;
private Map<String, List<String>> projectEnvMap;
/**
* 导出保存国际化
*/

View File

@ -0,0 +1,13 @@
package io.metersphere.track.dto.testplan;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TestPlanApiCaseInfoDTO {
private String id;
private String apiCaseId;
private String environmentId;
private String projectId;
}

View File

@ -0,0 +1,13 @@
package io.metersphere.track.dto.testplan;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TestPlanApiScenarioInfoDTO {
private String id;
private String apiScenarioId;
private String environment;
private String projectId;
}

View File

@ -0,0 +1,37 @@
package io.metersphere.track.dto.testplan;
import lombok.Getter;
import lombok.Setter;
import java.util.HashMap;
import java.util.Map;
@Getter
@Setter
public class TestPlanReportRunInfoDTO {
private String envGroupId;
private String runMode;
// <测试计划场景关联表ID, <项目ID环境ID>>
private Map<String, Map<String,String>> scenarioRunInfo;
// <测试计划用例关联表ID, <项目ID环境ID>>
private Map<String, Map<String,String>> apiCaseRunInfo;
public TestPlanReportRunInfoDTO(){
scenarioRunInfo = new HashMap<>();
apiCaseRunInfo = new HashMap<>();
}
public void putScenarioRunInfo(String scenarioResourceId,String projectId,String environmentId){
scenarioRunInfo.put(scenarioResourceId,new HashMap<>(){{
this.put(projectId,environmentId);
}});
}
public void putApiCaseRunInfo(String apiCaseResourceId,String projectId,String environmentId){
apiCaseRunInfo.put(apiCaseResourceId,new HashMap<>(){{
this.put(projectId,environmentId);
}});
}
}

View File

@ -7,18 +7,24 @@ import io.metersphere.api.dto.automation.TestPlanFailureApiDTO;
import io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO;
import io.metersphere.api.service.ApiDefinitionExecResultService;
import io.metersphere.api.service.ApiScenarioReportService;
import io.metersphere.api.service.ShareInfoService;
import io.metersphere.api.service.ApiTestEnvironmentService;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.*;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.*;
import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.dto.TestPlanExecuteReportDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.service.EnvironmentGroupProjectService;
import io.metersphere.service.EnvironmentGroupService;
import io.metersphere.service.ProjectService;
import io.metersphere.service.UserService;
import io.metersphere.track.dto.*;
import io.metersphere.track.dto.testplan.TestPlanApiCaseInfoDTO;
import io.metersphere.track.dto.testplan.TestPlanApiScenarioInfoDTO;
import io.metersphere.track.dto.testplan.TestPlanReportRunInfoDTO;
import io.metersphere.track.request.report.QueryTestPlanReportRequest;
import io.metersphere.track.request.report.TestPlanReportSaveRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
@ -70,14 +76,8 @@ public class TestPlanReportService {
@Resource
TestPlanReportContentMapper testPlanReportContentMapper;
@Resource
ShareInfoService shareInfoService;
@Resource
private TestPlanPrincipalMapper testPlanPrincipalMapper;
@Resource
private UserService userService;
@Resource
private ProjectService projectService;
@Resource
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
@Resource
private ExtLoadTestReportMapper extLoadTestReportMapper;
@ -96,6 +96,14 @@ public class TestPlanReportService {
private TestPlanExecutionQueueMapper testPlanExecutionQueueMapper;
@Resource
private TestPlanMessageService testPlanMessageService;
@Resource
private EnvironmentGroupProjectService environmentGroupProjectService;
@Resource
private EnvironmentGroupService environmentGroupService;
@Resource
private ApiTestEnvironmentService apiTestEnvironmentService;
@Resource
private ProjectService projectService;
public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) {
List<TestPlanReportDTO> list = new ArrayList<>();
@ -214,7 +222,7 @@ public class TestPlanReportService {
}
}
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String planReportId, String planId, String userId, String triggerMode) {
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String planReportId, String planId, String userId, String triggerMode, RunModeConfigDTO runModeConfigDTO) {
TestPlanReport testPlanReport = this.getTestPlanReport(planReportId);
TestPlanScheduleReportInfoDTO returnDTO = new TestPlanScheduleReportInfoDTO();
if (testPlanReport != null) {
@ -224,14 +232,19 @@ public class TestPlanReportService {
Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
Map<String, String> planTestCaseIdMap = new LinkedHashMap<>();
Map<String, String> performanceIdMap = new LinkedHashMap<>();
List<TestPlanApiScenario> testPlanApiScenarioList = extTestPlanScenarioCaseMapper.selectLegalDataByTestPlanId(planId);
for (TestPlanApiScenario model : testPlanApiScenarioList) {
List<TestPlanApiScenarioInfoDTO> testPlanApiScenarioList = extTestPlanScenarioCaseMapper.selectLegalDataByTestPlanId(planId);
for (TestPlanApiScenarioInfoDTO model : testPlanApiScenarioList) {
planScenarioIdMap.put(model.getId(), model.getApiScenarioId());
}
List<TestPlanApiCase> testPlanApiCaseList = extTestPlanApiCaseMapper.selectLegalDataByTestPlanId(planId);
for (TestPlanApiCase model : testPlanApiCaseList) {
List<TestPlanApiCaseInfoDTO> testPlanApiCaseList = extTestPlanApiCaseMapper.selectLegalDataByTestPlanId(planId);
for (TestPlanApiCaseInfoDTO model : testPlanApiCaseList) {
planTestCaseIdMap.put(model.getId(), model.getApiCaseId());
}
//解析运行环境信息
TestPlanReportRunInfoDTO runInfoDTO = this.parseTestPlanRunInfo(runModeConfigDTO, testPlanApiCaseList, testPlanApiScenarioList);
LoadCaseRequest loadCaseRequest = new LoadCaseRequest();
loadCaseRequest.setTestPlanId(planId);
List<TestPlanLoadCaseDTO> testPlanLoadCaseDTOList = extTestPlanLoadCaseMapper.selectTestPlanLoadCaseList(loadCaseRequest);
@ -257,7 +270,7 @@ public class TestPlanReportService {
apiCaseInfoMap, scenarioInfoMap, performanceInfoMap);
if (testPlanReport == null) {
returnDTO = this.genTestPlanReport(saveRequest);
returnDTO = this.genTestPlanReport(saveRequest, runInfoDTO);
}
returnDTO.setPlanScenarioIdMap(planScenarioIdMap);
returnDTO.setApiTestCaseDataMap(planTestCaseIdMap);
@ -266,6 +279,42 @@ public class TestPlanReportService {
return returnDTO;
}
public TestPlanReportRunInfoDTO parseTestPlanRunInfo(RunModeConfigDTO runModeConfigDTO, List<TestPlanApiCaseInfoDTO> testPlanApiCaseList, List<TestPlanApiScenarioInfoDTO> testPlanApiScenarioList) {
TestPlanReportRunInfoDTO runInfoDTO = new TestPlanReportRunInfoDTO();
Map<String, String> selectEnvMap = runModeConfigDTO.getEnvMap();
runInfoDTO.setRunMode(runModeConfigDTO.getMode());
if (StringUtils.equals("GROUP", runModeConfigDTO.getEnvironmentType()) && StringUtils.isNotEmpty(runModeConfigDTO.getEnvironmentGroupId())) {
selectEnvMap = environmentGroupProjectService.getEnvMap(runModeConfigDTO.getEnvironmentGroupId());
runInfoDTO.setEnvGroupId(runModeConfigDTO.getEnvironmentGroupId());
}
for (TestPlanApiScenarioInfoDTO model : testPlanApiScenarioList) {
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
} else if (StringUtils.isNotEmpty(model.getEnvironment())) {
try {
Map<String, String> envMap = JSONObject.parseObject(model.getEnvironment(), Map.class);
if (MapUtils.isNotEmpty(envMap)) {
String envId = null;
for (String envIdStr : envMap.values()) {
envId = envIdStr;
}
runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), envId);
}
} catch (Exception ignore) {
}
}
}
for (TestPlanApiCaseInfoDTO model : testPlanApiCaseList) {
if (MapUtils.isNotEmpty(selectEnvMap) && selectEnvMap.containsKey(model.getProjectId())) {
runInfoDTO.putApiCaseRunInfo(model.getId(), model.getProjectId(), selectEnvMap.get(model.getProjectId()));
} else {
runInfoDTO.putApiCaseRunInfo(model.getId(), model.getProjectId(), model.getEnvironmentId());
}
}
return runInfoDTO;
}
/**
* saveRequest.reportId 报告ID(外部传入
* saveRequest.planId 测试计划ID
@ -276,7 +325,7 @@ public class TestPlanReportService {
* saveRequest.scenarioIsExecuting 场景案例是否执行中
* saveRequest.performanceIsExecuting 性能案例是否执行中
*/
public TestPlanScheduleReportInfoDTO genTestPlanReport(TestPlanReportSaveRequest saveRequest) {
public TestPlanScheduleReportInfoDTO genTestPlanReport(TestPlanReportSaveRequest saveRequest, TestPlanReportRunInfoDTO runInfoDTO) {
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(saveRequest.getPlanId());
String testPlanReportID = saveRequest.getReportID();
TestPlanReport testPlanReport = new TestPlanReport();
@ -297,14 +346,15 @@ public class TestPlanReportService {
testPlanReport.setStartTime(System.currentTimeMillis());
testPlanReport.setEndTime(System.currentTimeMillis());
testPlanReport.setIsNew(true);
testPlanReport.setRunInfo(JSONObject.toJSONString(runInfoDTO));
if (saveRequest.isCountResources()) {
List<TestPlanApiCase> testPlanApiCaseList = extTestPlanApiCaseMapper.selectLegalDataByTestPlanId(saveRequest.getPlanId());
List<String> apiCaseIdList = testPlanApiCaseList.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList());
List<TestPlanApiCaseInfoDTO> testPlanApiCaseList = extTestPlanApiCaseMapper.selectLegalDataByTestPlanId(saveRequest.getPlanId());
List<String> apiCaseIdList = testPlanApiCaseList.stream().map(TestPlanApiCaseInfoDTO::getApiCaseId).collect(Collectors.toList());
testPlanReport.setIsApiCaseExecuting(!apiCaseIdList.isEmpty());
List<TestPlanApiScenario> testPlanApiScenarioList = extTestPlanScenarioCaseMapper.selectLegalDataByTestPlanId(saveRequest.getPlanId());
List<String> scenarioIdList = testPlanApiScenarioList.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList());
List<TestPlanApiScenarioInfoDTO> testPlanApiScenarioList = extTestPlanScenarioCaseMapper.selectLegalDataByTestPlanId(saveRequest.getPlanId());
List<String> scenarioIdList = testPlanApiScenarioList.stream().map(TestPlanApiScenarioInfoDTO::getApiScenarioId).collect(Collectors.toList());
testPlanReport.setIsScenarioExecuting(!scenarioIdList.isEmpty());
LoadCaseRequest loadCaseRequest = new LoadCaseRequest();
@ -829,12 +879,11 @@ public class TestPlanReportService {
return null;
}
if (this.isDynamicallyGenerateReports(testPlanReportContent)) {
LogUtil.info("----> GenerateReports: " + JSONObject.toJSONString(testPlanReportContent));
testPlanReportContent = this.dynamicallyGenerateReports(testPlanReportContent);
LogUtil.info("----> GenerateReports OVER: " + JSONObject.toJSONString(testPlanReportContent));
}
TestPlanSimpleReportDTO testPlanReportDTO = new TestPlanSimpleReportDTO();
BeanUtils.copyBean(testPlanReportDTO, testPlanReportContent);
this.generateEnvironmentInfo(testPlanReportDTO, reportId);
if (StringUtils.isNotBlank(testPlanReportContent.getFunctionResult())) {
testPlanReportDTO.setFunctionResult(JSONObject.parseObject(testPlanReportContent.getFunctionResult(), TestPlanFunctionResultReportDTO.class));
}
@ -889,6 +938,70 @@ public class TestPlanReportService {
return testPlanReportDTO;
}
private void generateEnvironmentInfo(TestPlanSimpleReportDTO testPlanReportDTO, String reportId) {
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(reportId);
TestPlanReportRunInfoDTO runInfoDTO = null;
if (StringUtils.isNotEmpty(testPlanReport.getRunInfo())) {
try {
runInfoDTO = JSONObject.parseObject(testPlanReport.getRunInfo(), TestPlanReportRunInfoDTO.class);
} catch (Exception e) {
LogUtil.error("解析测试计划报告记录的运行环境信息[" + testPlanReport.getRunInfo() + "]时出错!", e);
}
}
if (runInfoDTO != null) {
if (StringUtils.isNotEmpty(runInfoDTO.getEnvGroupId())) {
EnvironmentGroup environmentGroup = environmentGroupService.selectById(runInfoDTO.getEnvGroupId());
if (StringUtils.isNotEmpty(environmentGroup.getName())) {
testPlanReportDTO.setEnvGroupName(environmentGroup.getName());
}
}
testPlanReportDTO.setRunMode(StringUtils.equalsIgnoreCase(runInfoDTO.getRunMode(), "serial") ? Translator.get("serial") : Translator.get("parallel"));
Map<String, Set<String>> projectEnvMap = new LinkedHashMap<>();
if (MapUtils.isNotEmpty(runInfoDTO.getApiCaseRunInfo())) {
this.setProjectEnvMap(projectEnvMap, runInfoDTO.getApiCaseRunInfo());
}
if (MapUtils.isNotEmpty(runInfoDTO.getScenarioRunInfo())) {
this.setProjectEnvMap(projectEnvMap, runInfoDTO.getScenarioRunInfo());
}
Map<String, List<String>> showProjectEnvMap = new LinkedHashMap<>();
for (Map.Entry<String, Set<String>> entry : projectEnvMap.entrySet()) {
String projectId = entry.getKey();
Set<String> envIdSet = entry.getValue();
String projectName = projectService.selectNameById(projectId);
List<String> envNames = apiTestEnvironmentService.selectNameByIds(envIdSet);
if (StringUtils.isNotEmpty(projectName) && CollectionUtils.isNotEmpty(envNames)) {
showProjectEnvMap.put(projectName, envNames);
}
}
if (MapUtils.isNotEmpty(showProjectEnvMap)) {
testPlanReportDTO.setProjectEnvMap(showProjectEnvMap);
}
}
}
private void setProjectEnvMap(Map<String, Set<String>> projectEnvMap, Map<String, Map<String, String>> caseEnvironmentMap) {
if (projectEnvMap == null || caseEnvironmentMap == null) {
return;
}
for (Map<String, String> map : caseEnvironmentMap.values()) {
if (MapUtils.isEmpty(map)) {
continue;
}
for (Map.Entry<String, String> entry : map.entrySet()) {
String projectId = entry.getKey();
String envId = entry.getValue();
if (projectEnvMap.containsKey(projectId)) {
projectEnvMap.get(projectId).add(envId);
} else {
projectEnvMap.put(projectId, new LinkedHashSet<>() {{
this.add(envId);
}});
}
}
}
}
private boolean isDynamicallyGenerateReports(TestPlanReportContentWithBLOBs testPlanReportContent) {
return testPlanReportContent != null &&
(StringUtils.isNotEmpty(testPlanReportContent.getPlanApiCaseReportStruct()) || StringUtils.isNotEmpty(testPlanReportContent.getPlanScenarioReportStruct()) || StringUtils.isNotEmpty(testPlanReportContent.getPlanLoadCaseReportStruct()));

View File

@ -951,8 +951,8 @@ public class TestPlanService {
}
@Transactional(propagation = Propagation.NOT_SUPPORTED)
TestPlanScheduleReportInfoDTO genTestPlanReport(String planReportId, String planId, String userId, String triggerMode) {
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(planReportId, planId, userId, triggerMode);
TestPlanScheduleReportInfoDTO genTestPlanReport(String planReportId, String planId, String userId, String triggerMode, RunModeConfigDTO runModeConfigDTO) {
TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(planReportId, planId, userId, triggerMode, runModeConfigDTO);
return reportInfoDTO;
}
@ -979,7 +979,7 @@ public class TestPlanService {
}
//创建测试报告然后返回的ID重新赋值为resourceID作为后续的参数
TestPlanScheduleReportInfoDTO reportInfoDTO = this.genTestPlanReport(planReportId, testPlanID, userId, triggerMode);
TestPlanScheduleReportInfoDTO reportInfoDTO = this.genTestPlanReport(planReportId, testPlanID, userId, triggerMode, runModeConfig);
//测试计划准备执行取消测试计划的实际结束时间
extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID);
@ -1435,6 +1435,11 @@ public class TestPlanService {
cases.forEach(item -> {
if (resultMap.get(item.getReportId()) != null &&
StringUtils.isNotBlank(resultMap.get(item.getReportId()).getContent())) {
ApiDefinitionExecResultWithBLOBs execResult = resultMap.get(item.getReportId());
JSONObject responseObj = JSONObject.parseObject(execResult.getContent());
if (StringUtils.isNotEmpty(execResult.getEnvConfig())) {
responseObj.put("envName", apiDefinitionService.getEnvNameByEnvConfig(execResult.getProjectId(), execResult.getEnvConfig()));
}
item.setResponse(resultMap.get(item.getReportId()).getContent());
}
});
@ -2172,7 +2177,8 @@ public class TestPlanService {
TestPlanWithBLOBs testPlan = testPlanMap.get(id);
String planReportId = UUID.randomUUID().toString();
//创建测试报告
this.genTestPlanReport(planReportId, testPlan.getId(), request.getUserId(), request.getTriggerMode());
// TODO: 2022/5/16 genTestPlanReport的runModeConfig先赋值为null日后这里需要将前台传递的具体数据填写进来
this.genTestPlanReport(planReportId, testPlan.getId(), request.getUserId(), request.getTriggerMode(), null);
//测试计划准备执行取消测试计划的实际结束时间
extTestPlanMapper.updateActualEndTimeIsNullById(testPlan.getId());
executeQueue.put(testPlan.getId(), planReportId);

View File

@ -86,8 +86,7 @@
<!-- <ignoreColumn column="clean_load_report_expr"/>-->
<!-- <ignoreColumn column="repeatable"/>-->
<!-- </table>-->
<table tableName="api_case_execution_info"/>
<table tableName="scenario_execution_info"/>
<table tableName="test_plan_report"/>
<!--<table tableName="enterprise_test_report_send_record"/>-->
<!--<table tableName="test_case_review_api_case"/>
<table tableName="test_case_review_load"/>

View File

@ -391,4 +391,6 @@ ui_element_locator_type=LocatorType
ui_element_import_template_name=Ui_element_templates
ui_element_import_template_sheet=Template
ui_element_already_exists_excel=There are duplicate data in the import file
ui_element_already_exists_data=An element with the same name already exists
ui_element_already_exists_data=An element with the same name already exists
serial=Serial
parallel=Parallel

View File

@ -390,4 +390,6 @@ ui_element_locator_type=定位类型
ui_element_import_template_name=元素库导入模板
ui_element_import_template_sheet=模板
ui_element_already_exists_excel=文件中存在多条相同数据
ui_element_already_exists_data=已经存在同名元素
ui_element_already_exists_data=已经存在同名元素
serial=串行
parallel=并行

View File

@ -389,4 +389,6 @@ ui_element_locator_type=定位類型
ui_element_import_template_name=元素庫導入模板
ui_element_import_template_sheet=模板
ui_element_already_exists_excel=文件中存在多條相同數據
ui_element_already_exists_data=已經存在同名元素
ui_element_already_exists_data=已經存在同名元素
serial=串行
parallel=並行

View File

@ -8,12 +8,14 @@
<el-button-group>
<el-tooltip class="item" effect="dark" content="left" :disabled="true" placement="left">
<el-button plain :class="{active: leftActive}" @click="changeTab('left')">{{$t('commons.scenario')}}</el-button>
<el-button plain :class="{active: leftActive}" @click="changeTab('left')">
{{ $t('commons.scenario') }}
</el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="right" :disabled="true" placement="right">
<el-button plain :class="{active: rightActive}" @click="changeTab('right')">
{{$t('api_test.definition.request.case')}}
{{ $t('api_test.definition.request.case') }}
</el-button>
</el-tooltip>
@ -146,7 +148,7 @@
<script>
import {getCurrentProjectID} from "@/common/js/utils";
import {REPORT_CASE_CONFIGS, REPORT_CONFIGS} from "../../../common/components/search/search-components";
import {_filter, _sort, getLastTableSortField} from "@/common/js/tableUtils";
import {_filter, _sort} from "@/common/js/tableUtils";
import MsRenameReportDialog from "@/business/components/common/components/report/MsRenameReportDialog";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
import MsRequestResultTail from "../../../api/definition/components/response/RequestResultTail";
@ -197,7 +199,7 @@ export default {
{text: "FakeError", value: 'errorReportResult'},
{text: 'Rerunning', value: 'Rerunning'},
],
reportTypeFilters:[],
reportTypeFilters: [],
reportScenarioFilters: [
{text: this.$t('api_test.scenario.independent') + this.$t('commons.scenario'), value: 'SCENARIO_INDEPENDENT'},
{text: this.$t('api_test.scenario.integrated') + this.$t('commons.scenario'), value: 'SCENARIO_INTEGRATED'}
@ -231,8 +233,8 @@ export default {
},
watch: {
'$route': 'init',
trashActiveDom(){
this.condition.filters={report_type:[]};
trashActiveDom() {
this.condition.filters = {report_type: []};
this.search();
}
},
@ -310,7 +312,7 @@ export default {
},
handleView(report) {
this.reportId = report.id;
if (report.status === 'Running' || report.status ==='Rerunning') {
if (report.status === 'Running' || report.status === 'Rerunning') {
this.$warning(this.$t('commons.run_warning'))
return;
}
@ -427,15 +429,15 @@ export default {
this.$refs.renameDialog.close();
});
},
changeTab(tabType){
changeTab(tabType) {
this.trashActiveDom = tabType;
if(tabType === 'right'){
if (tabType === 'right') {
this.condition.components = REPORT_CASE_CONFIGS;
}else {
} else {
this.condition.components = REPORT_CONFIGS;
}
this.loadIsOver = false;
this.$nextTick( () => {
this.$nextTick(() => {
this.loadIsOver = true;
});
},
@ -452,13 +454,14 @@ export default {
.table-content {
width: 100%;
}
.active {
border: solid 1px #6d317c!important;
background-color: var(--primary_color)!important;
color: #FFFFFF!important;
border: solid 1px #6d317c !important;
background-color: var(--primary_color) !important;
color: #FFFFFF !important;
}
.item{
.item {
height: 32px;
padding: 5px 8px;
border: solid 1px var(--primary_color);

View File

@ -3,59 +3,72 @@
<el-row>
<el-col>
<span v-if="!debug">
<el-input v-if="nameIsEdit" size="mini" @blur="handleSave(report.name)" @keyup.enter.native="handleSaveKeyUp" style="width: 200px" v-model="report.name" maxlength="60" show-word-limit/>
<el-input v-if="nameIsEdit" size="mini" @blur="handleSave(report.name)" @keyup.enter.native="handleSaveKeyUp"
style="width: 200px" v-model="report.name" maxlength="60" show-word-limit/>
<span v-else>
<router-link v-if="isSingleScenario" :to="{name: isUi ? 'uiAutomation' : 'ApiAutomation', params: { dataSelectRange: 'edit:' + scenarioId }}">
<router-link v-if="isSingleScenario"
:to="{name: isUi ? 'uiAutomation' : 'ApiAutomation', params: { dataSelectRange: 'edit:' + scenarioId }}">
{{ report.name }}
</router-link>
<span v-else>
{{ report.name }}
</span>
<i v-if="showCancelButton" class="el-icon-edit" style="cursor:pointer" @click="nameIsEdit = true" @click.stop/>
<i v-if="showCancelButton" class="el-icon-edit" style="cursor:pointer" @click="nameIsEdit = true"
@click.stop/>
</span>
</span>
<span v-if="report.endTime || report.createTime">
<span style="margin-left: 10px">{{$t('report.test_start_time')}}</span>
<span style="margin-left: 10px">{{ $t('report.test_start_time') }}</span>
<span class="time"> {{ report.createTime | timestampFormatDate }}</span>
<span style="margin-left: 10px">{{$t('report.test_end_time')}}</span>
<span style="margin-left: 10px">{{ $t('report.test_end_time') }}</span>
<span class="time"> {{ report.endTime | timestampFormatDate }}</span>
</span>
<div style="float: right">
<el-button v-if="!isPlan && (!debug || exportFlag) && !isTemplate && !isUi" v-permission="['PROJECT_API_REPORT:READ+EXPORT']" :disabled="isReadOnly" class="export-button" plain type="primary" size="mini" @click="handleExport(report.name)" style="margin-right: 10px">
{{ $t('test_track.plan_view.export_report') }}
</el-button>
<el-popover
v-if="!isPlan && (!debug || exportFlag) && !isTemplate && !isUi"
v-permission="['PROJECT_PERFORMANCE_REPORT:READ+EXPORT']"
style="margin-right: 10px;float: right;"
placement="bottom"
width="300">
<p>{{ shareUrl }}</p>
<span style="color: red;float: left;margin-left: 10px;" v-if="application.typeValue">{{
$t('commons.validity_period')+application.typeValue
}}</span>
<div style="text-align: right; margin: 0">
<el-button type="primary" size="mini" :disabled="!shareUrl"
v-clipboard:copy="shareUrl">{{ $t("commons.copy") }}
</el-button>
</div>
<el-button slot="reference" :disabled="isReadOnly" type="danger" plain size="mini"
@click="handleShare(report)">
{{ $t('test_track.plan_view.share_report') }}
<el-button v-if="!isPlan && (!debug || exportFlag) && !isTemplate && !isUi"
v-permission="['PROJECT_API_REPORT:READ+EXPORT']" :disabled="isReadOnly" class="export-button"
plain type="primary" size="mini" @click="handleExport(report.name)" style="margin-right: 10px">
{{ $t('test_track.plan_view.export_report') }}
</el-button>
</el-popover>
<el-button v-if="showRerunButton" class="rerun-button" plain size="mini" @click="rerun" >
{{$t('api_test.automation.rerun')}}
</el-button>
<el-popover
v-if="!isPlan && (!debug || exportFlag) && !isTemplate && !isUi"
v-permission="['PROJECT_PERFORMANCE_REPORT:READ+EXPORT']"
style="margin-right: 10px;float: right;"
placement="bottom"
width="300">
<p>{{ shareUrl }}</p>
<span style="color: red;float: left;margin-left: 10px;" v-if="application.typeValue">{{
$t('commons.validity_period') + application.typeValue
}}</span>
<div style="text-align: right; margin: 0">
<el-button type="primary" size="mini" :disabled="!shareUrl"
v-clipboard:copy="shareUrl">{{ $t("commons.copy") }}
</el-button>
</div>
<el-button slot="reference" :disabled="isReadOnly" type="danger" plain size="mini"
@click="handleShare(report)">
{{ $t('test_track.plan_view.share_report') }}
</el-button>
</el-popover>
<el-button v-if="showCancelButton" class="export-button" plain size="mini" @click="returnView" >
{{$t('commons.cancel')}}
</el-button>
<el-button v-if="showRerunButton" class="rerun-button" plain size="mini" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
<el-button v-if="showCancelButton" class="export-button" plain size="mini" @click="returnView">
{{ $t('commons.cancel') }}
</el-button>
</div>
</el-col>
</el-row>
<el-row v-if="showProjectEnv" type="flex">
<span> {{ $t('commons.environment') + ':' }} </span>
<div v-for="(values,key) in projectEnvMap" :key="key" style="margin-right: 10px">
{{ key + ":" }}
<ms-tag v-for="(item,index) in values" :key="index" type="success" :content="item"
style="margin-left: 2px"/>
</div>
</el-row>
</header>
</template>
@ -63,11 +76,14 @@
import {generateShareInfoWithExpired} from "@/network/share";
import {getCurrentProjectID} from "@/common/js/utils";
import MsTag from "@/business/components/common/components/MsTag";
export default {
name: "MsApiReportViewHeader",
components: {MsTag},
props: {
report: {},
projectEnvMap: {},
debug: Boolean,
showCancelButton: {
type: Boolean,
@ -85,6 +101,9 @@ export default {
isPlan: Boolean
},
computed: {
showProjectEnv() {
return this.projectEnvMap && JSON.stringify(this.projectEnvMap) !== '{}';
},
path() {
return "/api/test/edit?id=" + this.report.testId;
},
@ -112,11 +131,10 @@ export default {
isReadOnly: false,
nameIsEdit: false,
shareUrl: "",
application:{}
application: {}
}
},
created() {
},
methods: {
handleExport(name) {
@ -129,19 +147,19 @@ export default {
handleSaveKeyUp($event) {
$event.target.blur();
},
rerun(){
rerun() {
let type = this.report.reportType;
let rerunObj = {type :type,reportId:this.report.id}
this.$post('/api/test/exec/rerun',rerunObj, res => {
if (res.data !=='SUCCESS') {
let rerunObj = {type: type, reportId: this.report.id}
this.$post('/api/test/exec/rerun', rerunObj, res => {
if (res.data !== 'SUCCESS') {
this.$error(res.data);
}else{
} else {
this.$success(this.$t('api_test.automation.rerun_success'));
this.returnView();
}
});
},
returnView(){
returnView() {
if (this.isUi) {
this.$router.push('/ui/report');
} else {
@ -158,22 +176,19 @@ export default {
this.shareUrl = thisHost + "/shareApiReport" + data.shareUrl;
});
},
getProjectApplication(){
this.$get('/project_application/get/' + getCurrentProjectID()+"/API_SHARE_REPORT_TIME", res => {
if(res.data){
getProjectApplication() {
this.$get('/project_application/get/' + getCurrentProjectID() + "/API_SHARE_REPORT_TIME", res => {
if (res.data) {
let quantity = res.data.typeValue.substring(0, res.data.typeValue.length - 1);
let unit = res.data.typeValue.substring(res.data.typeValue.length - 1);
if(unit==='H'){
res.data.typeValue = quantity+this.$t('commons.date_unit.hour');
}else
if(unit==='D'){
res.data.typeValue = quantity+this.$t('commons.date_unit.day');
}else
if(unit==='M'){
res.data.typeValue = quantity+this.$t('commons.workspace_unit')+this.$t('commons.date_unit.month');
}else
if(unit==='Y'){
res.data.typeValue = quantity+this.$t('commons.date_unit.year');
if (unit === 'H') {
res.data.typeValue = quantity + this.$t('commons.date_unit.hour');
} else if (unit === 'D') {
res.data.typeValue = quantity + this.$t('commons.date_unit.day');
} else if (unit === 'M') {
res.data.typeValue = quantity + this.$t('commons.workspace_unit') + this.$t('commons.date_unit.month');
} else if (unit === 'Y') {
res.data.typeValue = quantity + this.$t('commons.date_unit.year');
}
this.application = res.data;
}
@ -190,7 +205,7 @@ export default {
margin-right: 10px;
}
.rerun-button{
.rerun-button {
float: right;
margin-right: 10px;
background-color: #F2F9EF;

View File

@ -54,13 +54,13 @@ export default {
this.websocket.onmessage = this.onMessages;
this.websocket.onerror = this.onError;
},
onError(){
onError() {
this.$emit('runRefresh', "");
this.$error("The connection is abnormal, please check the environment configuration");
},
onMessages(e) {
//
if(e && e.data === "CONN_SUCCEEDED"){
if (e && e.data === "CONN_SUCCEEDED") {
this.run();
}
@ -84,7 +84,10 @@ export default {
stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
}
if (stepArray[i].type === "Assertions" && !stepArray[i].document) {
stepArray[i].document = {type: "JSON", data: {xmlFollowAPI: false, jsonFollowAPI: false, json: [], xml: []}};
stepArray[i].document = {
type: "JSON",
data: {xmlFollowAPI: false, jsonFollowAPI: false, json: [], xml: []}
};
}
if (stepArray[i] && stepArray[i].authManager && !stepArray[i].authManager.clazzName) {
stepArray[i].authManager.clazzName = TYPE_TO_C.get(stepArray[i].authManager.type);
@ -122,7 +125,14 @@ export default {
})
this.sort(testPlan.hashTree);
this.requestResult.reportId = this.reportId;
let reqObj = {id: this.reportId, testElement: testPlan, type: this.type, clazzName: this.clazzName ? this.clazzName : TYPE_TO_C.get(this.type), projectId: projectId, environmentMap: strMapToObj(this.envMap)};
let reqObj = {
id: this.reportId,
testElement: testPlan,
type: this.type,
clazzName: this.clazzName ? this.clazzName : TYPE_TO_C.get(this.type),
projectId: projectId,
environmentMap: strMapToObj(this.envMap)
};
let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
reqObj.editCaseRequest = this.editCaseRequest;
reqObj.debug = this.debug;
@ -131,6 +141,9 @@ export default {
} else {
reqObj.name = this.runData[0].path;
}
if (this.runData[0].useEnvironment) {
reqObj.environmentId = this.runData[0].useEnvironment;
}
reqObj.reportId = this.reportId;
let url = "/api/definition/run/debug";
if (!this.debug) {

View File

@ -8,7 +8,9 @@
:content="responseResult.responseCode"
placement="top">
<div v-if="response.attachInfoMap && response.attachInfoMap.errorReportResult && response.attachInfoMap.status === 'errorReportResult'" class="node-title" :class="'ms-req-error-report-result'">
<div
v-if="response.attachInfoMap && response.attachInfoMap.errorReportResult && response.attachInfoMap.status === 'errorReportResult'"
class="node-title" :class="'ms-req-error-report-result'">
{{ responseResult && responseResult.responseCode ? responseResult.responseCode : '0' }}
</div>
<div v-else class="node-title" :class="response && response.success ?'ms-req-success':'ms-req-error'">
@ -19,10 +21,12 @@
{{ responseResult && responseResult.responseCode ? responseResult.responseCode : '0' }}
</div>
<div v-if="response && response.attachInfoMap && response.attachInfoMap.errorReportResult">
<div class="node-title ms-req-error-report-result" v-if="response.attachInfoMap.status === 'errorReportResult'" style="margin-left: 0px;padding-left: 0px">
<div class="node-title ms-req-error-report-result"
v-if="response.attachInfoMap.status === 'errorReportResult'" style="margin-left: 0px;padding-left: 0px">
{{ response.attachInfoMap.errorReportResult }}
</div>
<div class="node-title ms-req-success" v-else-if="response.success" style="margin-left: 0px;padding-left: 0px">
<div class="node-title ms-req-success" v-else-if="response.success"
style="margin-left: 0px;padding-left: 0px">
{{ response.attachInfoMap.errorReportResult }}
</div>
<div class="node-title ms-req-error" v-else style="margin-left: 0px;padding-left: 0px">
@ -32,13 +36,25 @@
</el-col>
<el-col>
<div style="font-size: 14px;color: #AAAAAA;float: left">{{ $t('api_report.response_time') }} :</div>
<div style="font-size: 14px;color:#61C550;margin-top:2px;margin-left:10px;float: left">{{ responseResult && responseResult.responseTime ? responseResult.responseTime : 0 }} ms</div>
<div style="font-size: 14px;color:#61C550;margin-top:2px;margin-left:10px;float: left">
{{ responseResult && responseResult.responseTime ? responseResult.responseTime : 0 }} ms
</div>
</el-col>
<el-col>
<div style="font-size: 14px;color: #AAAAAA;float: left">{{ $t('api_report.response_size') }} :</div>
<div style="font-size: 14px;color:#61C550; margin-top:2px;margin-left:10px;float: left">{{ responseResult && responseResult.responseSize ? responseResult.responseSize : 0 }} bytes</div>
<div style="font-size: 14px;color:#61C550; margin-top:2px;margin-left:10px;float: left">
{{ responseResult && responseResult.responseSize ? responseResult.responseSize : 0 }} bytes
</div>
</el-col>
</el-row>
<el-row type="flex" v-if="response.envName">
<div style="font-size: 14px;color: #AAAAAA;float: left">
<span> {{ $t('commons.environment') + ':' }} </span>
</div>
<div style="font-size: 14px;color:#61C550; margin-left:10px;float: left">
{{ response.envName }}
</div>
</el-row>
</div>
</template>

View File

@ -2,23 +2,38 @@
<test-plan-report-container id="overview" :title="$t('test_track.report.overview')">
<el-form class="form-info" v-loading="result.loading">
<el-form-item :label="$t('test_track.report.testing_time') + ':'">
{{showTime}}
{{ showTime }}
</el-form-item>
<el-row type="flex" class="select-time"
v-if="report.envGroupName || report.projectEnvMap">
<span> {{ $t('commons.environment') + ':' }} </span>
<div v-if="report.envGroupName" style="margin-left: 12px">
<ms-tag type="danger" :content="$t('commons.group')"></ms-tag>
{{ report.envGroupName }}
</div>
<div v-else-if="report.projectEnvMap" style="margin-left: 12px">
<div v-for="(values,key) in report.projectEnvMap" :key="key" style="margin-right: 10px">
{{ key + ":" }}
<ms-tag v-for="(item,index) in values" :key="index" type="success" :content="item"
style="margin-left: 2px"/>
</div>
</div>
</el-row>
<el-row type="flex" justify="space-between" class="select-time">
<el-col :span="8">
<el-form-item :label="$t('test_track.report.total_number_tests') + ':'">
{{report.caseCount}}
{{ report.caseCount }}
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('test_track.report.exacutive_rate') + ':'">
{{ (report.executeRate ? (report.executeRate * 100).toFixed(1) : 0) + '%'}}
{{ (report.executeRate ? (report.executeRate * 100).toFixed(1) : 0) + '%' }}
<ms-instructions-icon :content="$t('test_track.report.exacutive_rate_tip')"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('test_track.report.passing_rate') + ':'">
{{ (report.passRate ? (report.passRate * 100 ).toFixed(1) : 0) + '%'}}
{{ (report.passRate ? (report.passRate * 100).toFixed(1) : 0) + '%' }}
<ms-instructions-icon :content="$t('test_track.report.passing_rate_tip')"/>
</el-form-item>
</el-col>
@ -33,9 +48,11 @@ import TestPlanReportContainer
from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportContainer";
import {timestampFormatDate} from "@/common/js/filter";
import MsInstructionsIcon from "@/business/components/common/components/MsInstructionsIcon";
import MsTag from "@/business/components/common/components/MsTag";
export default {
name: "TestPlanOverviewReport",
components: {MsInstructionsIcon, TestPlanReportContainer, MsFormDivider},
components: {MsInstructionsIcon, TestPlanReportContainer, MsFormDivider, MsTag},
props: {
report: Object,
},

View File

@ -13,33 +13,33 @@
:data="apiCases">
<ms-table-column
:width="80"
:label="$t('commons.id')"
prop="num">
:width="80"
:label="$t('commons.id')"
prop="num">
</ms-table-column>
<ms-table-column
:label="$t('commons.name')"
prop="name">
:label="$t('commons.name')"
prop="name">
</ms-table-column>
<ms-table-column
:label="$t('commons.create_user')"
prop="creatorName"/>
:label="$t('commons.create_user')"
prop="creatorName"/>
<ms-table-column
:label="$t('test_track.case.priority')"
:width="80"
prop="priority">
:label="$t('test_track.case.priority')"
:width="80"
prop="priority">
<template v-slot:default="scope">
<priority-table-item :value="scope.row.priority" ref="priority"/>
</template>
</ms-table-column>
<ms-table-column
:width="80"
:label="$t('test_track.plan_view.execute_result')"
prop="lastResult">
:width="80"
:label="$t('test_track.plan_view.execute_result')"
prop="lastResult">
<template v-slot:default="scope">
<status-table-item v-if="scope.row.execResult === 'success'" :value="'Pass'"/>
<status-table-item v-else-if="scope.row.execResult === 'error'" :value="'Failure'"/>
@ -69,10 +69,14 @@ import TypeTableItem from "../../../../../../common/tableItems/planview/TypeTabl
import MethodTableItem from "../../../../../../common/tableItems/planview/MethodTableItem";
import StatusTableItem from "../../../../../../common/tableItems/planview/StatusTableItem";
import {
getPlanApiAllCase, getPlanApiErrorReportCase,
getPlanApiFailureCase, getPlanApiUnExecuteCase,
getSharePlanApiAllCase, getSharePlanApiErrorReportCase,
getSharePlanApiFailureCase, getSharePlanApiUnExecuteCase
getPlanApiAllCase,
getPlanApiErrorReportCase,
getPlanApiFailureCase,
getPlanApiUnExecuteCase,
getSharePlanApiAllCase,
getSharePlanApiErrorReportCase,
getSharePlanApiFailureCase,
getSharePlanApiUnExecuteCase
} from "@/network/test-plan";
import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";