parent
ea0642eeca
commit
3f00e66597
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.api.dto.plan;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AutomationsRunInfoDTO {
|
||||
List<String> resourcePools;
|
||||
Map<String, List<String>> projectEnvMap;
|
||||
}
|
|
@ -12,4 +12,6 @@ public interface ExtApiScenarioModuleMapper {
|
|||
void updatePos(String id, Double pos);
|
||||
|
||||
List<ApiScenarioModuleDTO> selectByIds(@Param("ids") Collection<String> ids);
|
||||
|
||||
List<String> selectResourcePoolIdByTestPlanScenarioIds(@Param("ids") List<String> resourceIds);
|
||||
}
|
||||
|
|
|
@ -25,4 +25,14 @@
|
|||
</foreach>
|
||||
order by api_scenario_module.pos asc
|
||||
</select>
|
||||
<select id="selectResourcePoolIdByTestPlanScenarioIds" resultType="java.lang.String">
|
||||
SELECT DISTINCT actuator FROM api_scenario_report WHERE id in (
|
||||
SELECT report_id FROM test_plan_api_scenario
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -62,5 +62,7 @@ public interface ExtTestPlanApiCaseMapper {
|
|||
String selectProjectId(String id);
|
||||
|
||||
List<TestPlanApiCase> selectByRefIds(@Param("ids") List<String> ids);
|
||||
|
||||
List<String> selectResourcePoolIdByTestPlanApiIds(@Param("ids") List<String> resourceIds);
|
||||
}
|
||||
|
||||
|
|
|
@ -555,4 +555,16 @@
|
|||
</foreach>
|
||||
ORDER BY t.order DESC
|
||||
</select>
|
||||
|
||||
<select id="selectResourcePoolIdByTestPlanApiIds" resultType="java.lang.String">
|
||||
|
||||
SELECT DISTINCT actuator FROM api_definition_exec_result execResult
|
||||
INNER JOIN (
|
||||
SELECT id, resource_id, max( create_time + 0 ) AS create_time
|
||||
FROM api_definition_exec_result WHERE resource_id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
) t ON execResult.id = t.id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.api.dto.QueryReferenceRequest;
|
|||
import io.metersphere.api.dto.automation.TestPlanApiDTO;
|
||||
import io.metersphere.api.dto.automation.TestPlanDTO;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.plan.AutomationsRunInfoDTO;
|
||||
import io.metersphere.api.dto.plan.TestPlanApiCaseBatchRequest;
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiScenarioReportWithBLOBs;
|
||||
|
@ -140,7 +141,7 @@ public class TestPlanApiCaseController {
|
|||
}
|
||||
|
||||
@PostMapping("/get/plan/env/map")
|
||||
public Map<String, List<String>> getPlanProjectEnvMap(@RequestBody List<String> resourceIds) {
|
||||
public AutomationsRunInfoDTO getPlanProjectEnvMap(@RequestBody List<String> resourceIds) {
|
||||
return testPlanApiCaseService.getPlanProjectEnvMap(resourceIds);
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ public class TestPlanScenarioCaseController {
|
|||
}
|
||||
|
||||
@PostMapping("/get/plan/env/map")
|
||||
public Map<String, List<String>> getPlanProjectEnvMap(@RequestBody List<String> resourceIds) {
|
||||
public AutomationsRunInfoDTO getPlanProjectEnvMap(@RequestBody List<String> resourceIds) {
|
||||
return testPlanScenarioCaseService.getPlanProjectEnvMap(resourceIds);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.api.dto.QueryReferenceRequest;
|
|||
import io.metersphere.api.dto.automation.TestPlanApiDTO;
|
||||
import io.metersphere.api.dto.automation.TestPlanDTO;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.dto.plan.AutomationsRunInfoDTO;
|
||||
import io.metersphere.api.dto.plan.TestPlanApiCaseBatchRequest;
|
||||
import io.metersphere.api.dto.plan.TestPlanApiCaseInfoDTO;
|
||||
import io.metersphere.api.exec.api.ApiCaseExecuteService;
|
||||
|
@ -521,8 +522,9 @@ public class TestPlanApiCaseService {
|
|||
return extTestPlanApiCaseMapper.selectProjectId(id);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
public AutomationsRunInfoDTO getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
Map<String, List<String>> result = new LinkedHashMap<>();
|
||||
List<String> resourcePoolIds = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(resourceIds)) {
|
||||
List<ApiDefinitionExecResultWithBLOBs> execResults = apiDefinitionExecResultService.selectByResourceIdsAndMaxCreateTime(resourceIds);
|
||||
Map<String, List<String>> projectConfigMap = new HashMap<>();
|
||||
|
@ -538,8 +540,12 @@ public class TestPlanApiCaseService {
|
|||
}
|
||||
});
|
||||
result = apiDefinitionService.getProjectEnvNameByEnvConfig(projectConfigMap);
|
||||
resourcePoolIds = extTestPlanApiCaseMapper.selectResourcePoolIdByTestPlanApiIds(resourceIds);
|
||||
}
|
||||
return result;
|
||||
AutomationsRunInfoDTO returnDTO = new AutomationsRunInfoDTO();
|
||||
returnDTO.setProjectEnvMap(result);
|
||||
returnDTO.setResourcePools(resourcePoolIds);
|
||||
return returnDTO;
|
||||
}
|
||||
|
||||
public void setProjectEnvMap(Map<String, List<String>> result, Map<String, List<String>> projectEnvMap) {
|
||||
|
|
|
@ -1093,13 +1093,18 @@ public class TestPlanScenarioCaseService {
|
|||
return extTestPlanScenarioCaseMapper.selectForPlanReport(planId);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
public AutomationsRunInfoDTO getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
AutomationsRunInfoDTO returnRunInfoDTO = new AutomationsRunInfoDTO();
|
||||
Map<String, List<String>> result = new LinkedHashMap<>();
|
||||
List<String> resourcePoolList = new ArrayList<>();
|
||||
if (!com.alibaba.nacos.common.utils.CollectionUtils.isEmpty(resourceIds)) {
|
||||
Map<String, List<String>> projectEnvMap = apiScenarioEnvService.selectProjectEnvMapByTestPlanScenarioIds(resourceIds);
|
||||
testPlanApiCaseService.setProjectEnvMap(result, projectEnvMap);
|
||||
resourcePoolList = extApiScenarioModuleMapper.selectResourcePoolIdByTestPlanScenarioIds(resourceIds);
|
||||
}
|
||||
return result;
|
||||
returnRunInfoDTO.setResourcePools(resourcePoolList);
|
||||
returnRunInfoDTO.setProjectEnvMap(result);
|
||||
return returnRunInfoDTO;
|
||||
}
|
||||
|
||||
public List<ApiScenarioModuleDTO> getNodeByPlanId(List<String> projectIds, String planId) {
|
||||
|
|
|
@ -43,4 +43,9 @@ public interface ExtTestPlanLoadCaseMapper {
|
|||
void updateStatusNullById(String id);
|
||||
|
||||
String selectPlanIdByTestPlanId(@Param("id") String id);
|
||||
|
||||
List<String> getResourcePoolByPlanId(String planId);
|
||||
|
||||
List<String> getCaseResourcePoolByPlanId(String planId);
|
||||
|
||||
}
|
||||
|
|
|
@ -367,4 +367,20 @@
|
|||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getResourcePoolByPlanId" resultType="java.lang.String">
|
||||
SELECT ltr.test_resource_pool_id
|
||||
FROM test_plan_load_case tplc
|
||||
INNER JOIN load_test_report ltr
|
||||
ON tplc.load_case_id = ltr.test_id
|
||||
WHERE tplc.test_plan_id = #{0}
|
||||
</select>
|
||||
|
||||
<select id="getCaseResourcePoolByPlanId" resultType="java.lang.String">
|
||||
SELECT lt.test_resource_pool_id
|
||||
FROM test_plan_load_case tplc
|
||||
INNER JOIN load_test lt
|
||||
ON tplc.load_case_id = lt.id
|
||||
WHERE tplc.test_plan_id = #{0}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -22,9 +22,9 @@ import io.metersphere.plan.service.TestPlanLoadCaseService;
|
|||
import io.metersphere.request.PlanSubReportRequest;
|
||||
import io.metersphere.request.ResetOrderRequest;
|
||||
import io.metersphere.request.RunTestPlanRequest;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping("/test/plan/load/case")
|
||||
|
@ -179,6 +179,16 @@ public class TestPlanLoadCaseController {
|
|||
return testPlanLoadCaseService.getStatus(planId);
|
||||
}
|
||||
|
||||
@GetMapping("/resource/pool/{planId}")
|
||||
public List<String> getResourcePoolByPlanId(@PathVariable String planId) {
|
||||
return testPlanLoadCaseService.getResourcePoolByPlanId(planId);
|
||||
}
|
||||
|
||||
@GetMapping("/resource/pool/case/{planId}")
|
||||
public List<String> getCaseResourcePoolByPlanId(@PathVariable String planId) {
|
||||
return testPlanLoadCaseService.getCaseResourcePoolByPlanId(planId);
|
||||
}
|
||||
|
||||
@GetMapping("/get/report/status/{planId}")
|
||||
public List<PlanReportCaseDTO> selectStatusForPlanReport(@PathVariable("planId") String planId) {
|
||||
return testPlanLoadCaseService.selectStatusForPlanReport(planId);
|
||||
|
|
|
@ -709,4 +709,12 @@ public class TestPlanLoadCaseService {
|
|||
.map(TestPlanLoadCaseDTO::getLoadCaseId)
|
||||
.collect(Collectors.toList()).isEmpty();
|
||||
}
|
||||
|
||||
public List<String> getResourcePoolByPlanId(String planId) {
|
||||
return extTestPlanLoadCaseMapper.getResourcePoolByPlanId(planId);
|
||||
}
|
||||
|
||||
public List<String> getCaseResourcePoolByPlanId(String planId) {
|
||||
return extTestPlanLoadCaseMapper.getCaseResourcePoolByPlanId(planId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.plan.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class AutomationsRunInfoDTO {
|
||||
List<String> resourcePools;
|
||||
Map<String, List<String>> projectEnvMap;
|
||||
}
|
|
@ -17,7 +17,7 @@ public class TestPlanReportRunInfoDTO {
|
|||
private String runMode;
|
||||
private Map<String, List<String>> requestEnvMap;
|
||||
|
||||
private String resourcePool;
|
||||
private List<String> resourcePools;
|
||||
|
||||
// <测试计划场景关联表ID, <项目ID,环境ID>>
|
||||
private Map<String, Map<String, List<String>>> scenarioRunInfo;
|
||||
|
|
|
@ -29,6 +29,8 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent {
|
|||
*/
|
||||
private String runMode;
|
||||
private String resourcePool;
|
||||
|
||||
private List<String> resourcePools;
|
||||
private String envGroupName;
|
||||
private Map<String, List<String>> projectEnvMap;
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ public class TestPlanReportService {
|
|||
returnDTO.setApiTestCaseDataMap(planApiCaseIdMap);
|
||||
}
|
||||
|
||||
|
||||
List<String> loadResourcePools = new ArrayList<>();
|
||||
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
Map<String, String> performanceIdMap = new LinkedHashMap<>();
|
||||
List<TestPlanLoadCaseDTO> testPlanLoadCaseDTOList = planTestPlanLoadCaseService.list(planId);
|
||||
|
@ -308,10 +308,10 @@ public class TestPlanReportService {
|
|||
}
|
||||
saveRequest.setPerformanceIsExecuting(!performanceIdMap.isEmpty());
|
||||
saveRequest.setPerformanceIdMap(performanceIdMap);
|
||||
|
||||
returnDTO.setPerformanceIdMap(performanceIdMap);
|
||||
}
|
||||
|
||||
loadResourcePools = planTestPlanLoadCaseService.selectResourcePoolsByPlan(planId);
|
||||
}
|
||||
|
||||
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
|
||||
Map<String, String> uiScenarioIdMap = new LinkedHashMap<>();
|
||||
|
@ -333,9 +333,13 @@ public class TestPlanReportService {
|
|||
returnDTO.setUiScenarioIdMap(uiScenarioIdMap);
|
||||
}
|
||||
|
||||
|
||||
if (testPlanReport == null) {
|
||||
runInfoDTO.setResourcePool(runModeConfigDTO.getResourcePoolId());
|
||||
runInfoDTO.setResourcePools(loadResourcePools);
|
||||
if (StringUtils.isNotEmpty(runModeConfigDTO.getResourcePoolId())) {
|
||||
if (!runInfoDTO.getResourcePools().contains(runModeConfigDTO.getResourcePoolId())) {
|
||||
runInfoDTO.getResourcePools().add(runModeConfigDTO.getResourcePoolId());
|
||||
}
|
||||
}
|
||||
returnDTO = this.genTestPlanReport(saveRequest, runInfoDTO);
|
||||
}
|
||||
returnDTO.setPlanScenarioIdMap(saveRequest.getScenarioIdMap());
|
||||
|
@ -1103,6 +1107,23 @@ public class TestPlanReportService {
|
|||
} else {
|
||||
report.setIsThirdPartIssue(true);
|
||||
}
|
||||
|
||||
//查找资源池
|
||||
if (CollectionUtils.isNotEmpty(report.getResourcePools())) {
|
||||
TestResourcePoolExample example = new TestResourcePoolExample();
|
||||
example.createCriteria().andIdIn(report.getResourcePools());
|
||||
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(resourcePoolList)) {
|
||||
ArrayList<String> resourcePoolName = new ArrayList<>();
|
||||
resourcePoolList.forEach(item -> {
|
||||
if (!resourcePoolName.contains(item.getName())) {
|
||||
resourcePoolName.add(item.getName());
|
||||
}
|
||||
});
|
||||
String resourcePoolNames = StringUtils.join(resourcePoolName.toArray(), StringUtils.SPACE);
|
||||
report.setResourcePool(resourcePoolNames);
|
||||
}
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
|
@ -1120,10 +1141,19 @@ public class TestPlanReportService {
|
|||
public void setEnvironmentToDTO(TestPlanSimpleReportDTO testPlanReportDTO, TestPlanReportRunInfoDTO runInfoDTO) {
|
||||
if (ObjectUtils.allNotNull(testPlanReportDTO, runInfoDTO)) {
|
||||
//查找资源池
|
||||
if (StringUtils.isNotEmpty(runInfoDTO.getResourcePool())) {
|
||||
TestResourcePool resourcePool = testResourcePoolMapper.selectByPrimaryKey(runInfoDTO.getResourcePool());
|
||||
if (resourcePool != null) {
|
||||
testPlanReportDTO.setResourcePool(resourcePool.getName());
|
||||
if (CollectionUtils.isNotEmpty(runInfoDTO.getResourcePools())) {
|
||||
TestResourcePoolExample example = new TestResourcePoolExample();
|
||||
example.createCriteria().andIdIn(runInfoDTO.getResourcePools());
|
||||
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(resourcePoolList)) {
|
||||
ArrayList<String> resourcePoolName = new ArrayList<>();
|
||||
resourcePoolList.forEach(item -> {
|
||||
if (!resourcePoolName.contains(item.getName())) {
|
||||
resourcePoolName.add(item.getName());
|
||||
}
|
||||
});
|
||||
String resourcePoolNames = StringUtils.join(resourcePoolName.toArray(), StringUtils.SPACE);
|
||||
testPlanReportDTO.setResourcePool(resourcePoolNames);
|
||||
}
|
||||
}
|
||||
// 环境组/运行环境
|
||||
|
|
|
@ -876,6 +876,7 @@ public class TestPlanService {
|
|||
if (haveExecCase(testPlanId, true)) {
|
||||
this.verifyPool(projectId, runModeConfig);
|
||||
}
|
||||
|
||||
//创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数
|
||||
TestPlanScheduleReportInfoDTO reportInfoDTO = this.genTestPlanReport(planReportId, testPlanId, userId, triggerMode, runModeConfig);
|
||||
//定时任务执行重新设置实际开始时间
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package io.metersphere.plan.service.remote.api;
|
||||
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiScenarioReportWithBLOBs;
|
||||
import io.metersphere.commons.constants.MicroServiceName;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.*;
|
||||
import io.metersphere.plan.dto.ApiModuleDTO;
|
||||
import io.metersphere.plan.dto.BatchRunDefinitionRequest;
|
||||
import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
|
||||
import io.metersphere.plan.dto.TestPlanSimpleReportDTO;
|
||||
import io.metersphere.plan.dto.*;
|
||||
import io.metersphere.plan.request.api.ApiTestCaseRequest;
|
||||
import io.metersphere.plan.service.TestPlanService;
|
||||
import io.metersphere.plan.utils.TestPlanReportUtil;
|
||||
import io.metersphere.plan.utils.TestPlanStatusCalculator;
|
||||
import io.metersphere.utils.DiscoveryUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
@ -50,30 +46,10 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
|
|||
calculatePlanReport(report, planReportCaseDTOS);
|
||||
//记录接口用例的运行环境信息
|
||||
List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList());
|
||||
try {
|
||||
if (MapUtils.isEmpty(report.getProjectEnvMap())) {
|
||||
report.setProjectEnvMap(getPlanProjectEnvMap(idList));
|
||||
} else {
|
||||
Map<String, List<String>> projectEnvMap = getPlanProjectEnvMap(idList);
|
||||
if (MapUtils.isNotEmpty(projectEnvMap)) {
|
||||
for (Map.Entry<String, List<String>> entry : projectEnvMap.entrySet()) {
|
||||
String project = entry.getKey();
|
||||
List<String> envList = entry.getValue();
|
||||
if (report.getProjectEnvMap().containsKey(project)) {
|
||||
for (String env : envList) {
|
||||
if (!report.getProjectEnvMap().get(project).contains(env)) {
|
||||
report.getProjectEnvMap().get(project).add(env);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
report.getProjectEnvMap().put(project, envList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
AutomationsRunInfoDTO automationsRunInfoDTO = getPlanProjectEnvMap(idList);
|
||||
if (automationsRunInfoDTO != null) {
|
||||
report.setProjectEnvMap(TestPlanReportUtil.mergeProjectEnvMap(report.getProjectEnvMap(), automationsRunInfoDTO.getProjectEnvMap()));
|
||||
report.setResourcePools(TestPlanReportUtil.mergeResourcePools(report.getResourcePools(), automationsRunInfoDTO.getResourcePools()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +108,8 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
|
|||
return microService.getForDataArray(serviceName, BASE_UEL + "/get/report/status/" + planId, PlanReportCaseDTO.class);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
return (Map<String, List<String>>) microService.postForData(serviceName, BASE_UEL + "/get/plan/env/map", resourceIds);
|
||||
public AutomationsRunInfoDTO getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
return microService.postForData(serviceName, BASE_UEL + "/get/plan/env/map", resourceIds, AutomationsRunInfoDTO.class);
|
||||
}
|
||||
|
||||
public List<MsExecResponseDTO> run(BatchRunDefinitionRequest request) {
|
||||
|
@ -217,7 +193,4 @@ public class PlanTestPlanApiCaseService extends ApiTestService {
|
|||
return microService.getForDataArray(serviceName, BASE_UEL + "/get/report/ext/" + planId, ApiDefinitionExecResultWithBLOBs.class);
|
||||
}
|
||||
|
||||
public List<ApiScenarioReportWithBLOBs> selectExtForPlanScenarioReport(String planId) {
|
||||
return microService.getForDataArray(serviceName, BASE_UEL + "/get/report/scenario/ext/" + planId, ApiScenarioReportWithBLOBs.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ import io.metersphere.plan.dto.*;
|
|||
import io.metersphere.plan.request.api.ApiPlanReportRequest;
|
||||
import io.metersphere.plan.request.api.ApiScenarioRequest;
|
||||
import io.metersphere.plan.service.TestPlanService;
|
||||
import io.metersphere.plan.utils.TestPlanReportUtil;
|
||||
import io.metersphere.plan.utils.TestPlanStatusCalculator;
|
||||
import io.metersphere.utils.DiscoveryUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -40,30 +40,10 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService {
|
|||
calculatePlanReport(report, planReportCaseDTOS);
|
||||
//记录接口用例的运行环境信息
|
||||
List<String> idList = planReportCaseDTOS.stream().map(PlanReportCaseDTO::getId).collect(Collectors.toList());
|
||||
try {
|
||||
if (MapUtils.isEmpty(report.getProjectEnvMap())) {
|
||||
report.setProjectEnvMap(getPlanProjectEnvMap(idList));
|
||||
} else {
|
||||
Map<String, List<String>> projectEnvMap = getPlanProjectEnvMap(idList);
|
||||
if (MapUtils.isNotEmpty(projectEnvMap)) {
|
||||
for (Map.Entry<String, List<String>> entry : projectEnvMap.entrySet()) {
|
||||
String project = entry.getKey();
|
||||
List<String> envList = entry.getValue();
|
||||
if (report.getProjectEnvMap().containsKey(project)) {
|
||||
for (String env : envList) {
|
||||
if (!report.getProjectEnvMap().get(project).contains(env)) {
|
||||
report.getProjectEnvMap().get(project).add(env);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
report.getProjectEnvMap().put(project, envList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
AutomationsRunInfoDTO automationsRunInfoDTO = getPlanProjectEnvMap(idList);
|
||||
if (automationsRunInfoDTO != null) {
|
||||
report.setProjectEnvMap(TestPlanReportUtil.mergeProjectEnvMap(report.getProjectEnvMap(), automationsRunInfoDTO.getProjectEnvMap()));
|
||||
report.setResourcePools(TestPlanReportUtil.mergeResourcePools(report.getResourcePools(), automationsRunInfoDTO.getResourcePools()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,8 +118,8 @@ public class PlanTestPlanScenarioCaseService extends ApiTestService {
|
|||
return microService.getForDataArray(serviceName, BASE_UEL + "/get/report/status/" + planId, PlanReportCaseDTO.class);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
return (Map<String, List<String>>) microService.postForData(serviceName, BASE_UEL + "/get/plan/env/map", resourceIds);
|
||||
public AutomationsRunInfoDTO getPlanProjectEnvMap(List<String> resourceIds) {
|
||||
return microService.postForData(serviceName, BASE_UEL + "/get/plan/env/map", resourceIds, AutomationsRunInfoDTO.class);
|
||||
}
|
||||
|
||||
public List<String> getExecResultByPlanId(String planId) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import io.metersphere.plan.request.api.ApiPlanReportRequest;
|
|||
import io.metersphere.plan.request.performance.LoadCaseRequest;
|
||||
import io.metersphere.plan.request.performance.LoadPlanReportDTO;
|
||||
import io.metersphere.plan.service.TestPlanService;
|
||||
import io.metersphere.plan.utils.TestPlanReportUtil;
|
||||
import io.metersphere.plan.utils.TestPlanStatusCalculator;
|
||||
import io.metersphere.utils.DiscoveryUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -40,6 +41,8 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
|
|||
if (DiscoveryUtil.hasService(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
List<PlanReportCaseDTO> planReportCaseDTOS = selectStatusForPlanReport(planId);
|
||||
calculatePlanReport(report, planReportCaseDTOS);
|
||||
List<String> resourcePools = selectResourcePoolsByPlanReport(planId);
|
||||
report.setResourcePools(TestPlanReportUtil.mergeResourcePools(report.getResourcePools(), resourcePools));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +121,11 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
|
|||
return microService.getForDataArray(serviceName, BASE_UEL + "/get/report/status/" + planId, PlanReportCaseDTO.class);
|
||||
}
|
||||
|
||||
public List<String> selectResourcePoolsByPlanReport(String planId) {
|
||||
return (List<String>) microService.getForData(serviceName, BASE_UEL + "/resource/pool/" + planId);
|
||||
}
|
||||
|
||||
|
||||
public Boolean hasFailCase(String planId, List<String> performanceIds) {
|
||||
return (Boolean) microService.postForData(serviceName, BASE_UEL + "/has/fail/" + planId, performanceIds);
|
||||
}
|
||||
|
@ -142,4 +150,7 @@ public class PlanTestPlanLoadCaseService extends LoadTestService {
|
|||
return (String) microService.getForData(serviceName, BASE_UEL + "/pool/" + loadReportId);
|
||||
}
|
||||
|
||||
public List<String> selectResourcePoolsByPlan(String planId) {
|
||||
return (List<String>) microService.getForData(serviceName, BASE_UEL + "/resource/pool/case/" + planId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,4 +135,17 @@ public class TestPlanReportUtil {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<String> mergeResourcePools(List<String> resourcePools, List<String> originResourcePools) {
|
||||
if (resourcePools == null) {
|
||||
resourcePools = new ArrayList<>();
|
||||
}
|
||||
if (originResourcePools == null) {
|
||||
return resourcePools;
|
||||
}
|
||||
List<String> returnList = new ArrayList<>();
|
||||
returnList.addAll(resourcePools);
|
||||
returnList.addAll(originResourcePools);
|
||||
return returnList.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue