mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 03:58:33 +08:00
fix(测试跟踪): 开源用户测试计划部分操作后端有报错
This commit is contained in:
parent
00fda9cbcf
commit
02062eee3e
@ -155,73 +155,61 @@ public class TestPlanReportService {
|
||||
// 测试计划报告各用例集合
|
||||
List<PlanReportCaseDTO> planReportCaseDTOS;
|
||||
|
||||
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
|
||||
|
||||
if (testPlanExecuteReportDTO == null) {
|
||||
try {
|
||||
|
||||
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
||||
// 接口用例
|
||||
planReportCaseDTOS = planTestPlanApiCaseService.selectStatusForPlanReport(planId);
|
||||
TestPlanStatusCalculator.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, ApiReportStatus.SUCCESS.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
||||
try {
|
||||
// 场景用例
|
||||
planReportCaseDTOS = planTestPlanScenarioCaseService.selectStatusForPlanReport(planId);
|
||||
TestPlanStatusCalculator.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, ApiReportStatus.SUCCESS.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
// 性能用例
|
||||
planReportCaseDTOS = planTestPlanLoadCaseService.selectStatusForPlanReport(planId);
|
||||
TestPlanStatusCalculator.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, ApiReportStatus.SUCCESS.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
} else {
|
||||
// 报告 ID 集合
|
||||
List<String> reportIds = null;
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap())) {
|
||||
// 接口用例
|
||||
try {
|
||||
// 接口用例
|
||||
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap())) {
|
||||
reportIds = new ArrayList<>(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap().values());
|
||||
planReportCaseDTOS = planApiDefinitionExecResultService.selectForPlanReport(reportIds);
|
||||
TestPlanStatusCalculator.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, ApiReportStatus.SUCCESS.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap())) {
|
||||
try {
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap())) {
|
||||
// 场景用例
|
||||
reportIds = new ArrayList<>(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap().values());
|
||||
planReportCaseDTOS = planApiScenarioReportService.selectForPlanReport(reportIds);
|
||||
TestPlanStatusCalculator.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, ApiReportStatus.SUCCESS.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanUiScenarioIdAndReportIdMap())) {
|
||||
try {
|
||||
|
||||
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanUiScenarioIdAndReportIdMap())) {
|
||||
// 场景用例
|
||||
reportIds = new ArrayList<>(testPlanExecuteReportDTO.getTestPlanUiScenarioIdAndReportIdMap().values());
|
||||
planReportCaseDTOS = planApiScenarioReportService.selectForPlanReport(reportIds);
|
||||
TestPlanStatusCalculator.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, ApiReportStatus.SUCCESS.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap())) {
|
||||
try {
|
||||
|
||||
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap())) {
|
||||
// 性能用例
|
||||
reportIds = new ArrayList<>(testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap().values());
|
||||
planReportCaseDTOS = planLoadTestReportService.getPlanReportCaseDTO(reportIds);
|
||||
TestPlanStatusCalculator.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, ApiReportStatus.SUCCESS.name());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
report.setExecuteRate(0.0);
|
||||
report.setPassRate(0.0);
|
||||
|
@ -480,25 +480,18 @@ public class TestPlanService {
|
||||
public void checkStatus(String testPlanId) { // 检查执行结果,自动更新计划状态
|
||||
List<String> statusList = new ArrayList<>();
|
||||
statusList.addAll(extTestPlanTestCaseMapper.getExecResultByPlanId(testPlanId));
|
||||
try {
|
||||
|
||||
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
|
||||
|
||||
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
||||
statusList.addAll(planTestPlanApiCaseService.getExecResultByPlanId(testPlanId));
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
try {
|
||||
statusList.addAll(planTestPlanScenarioCaseService.getExecResultByPlanId(testPlanId));
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
try {
|
||||
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
statusList.addAll(planTestPlanLoadCaseService.getExecResultByPlanId(testPlanId));
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
try {
|
||||
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
|
||||
statusList.addAll(planTestPlanUiScenarioCaseService.getExecResultByPlanId(testPlanId));
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
||||
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
|
||||
@ -638,12 +631,13 @@ public class TestPlanService {
|
||||
}
|
||||
|
||||
private void startRelevance(PlanCaseRelevanceRequest request, List<String> apiCaseIds, List<String> scenarioIds, List<String> performanceIds) {
|
||||
try {
|
||||
relevanceTestCaseTest(apiCaseIds, request.getPlanId(), planTestPlanApiCaseService::relevanceByTestIds);
|
||||
relevanceTestCaseTest(scenarioIds, request.getPlanId(), planTestPlanScenarioCaseService::relevanceByTestIds);
|
||||
relevanceTestCaseTest(performanceIds, request.getPlanId(), planTestPlanLoadCaseService::relevanceByTestIds);
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
|
||||
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
||||
planTestPlanApiCaseService.relevanceByTestIds(apiCaseIds, request.getPlanId());
|
||||
planTestPlanScenarioCaseService.relevanceByTestIds(scenarioIds, request.getPlanId());
|
||||
}
|
||||
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
planTestPlanLoadCaseService.relevanceByTestIds(performanceIds, request.getPlanId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -661,14 +655,6 @@ public class TestPlanService {
|
||||
}
|
||||
}
|
||||
|
||||
public void relevanceTestCaseTest(List<String> ids, String planId, BiConsumer<List<String>, String> relevanceByTestIds) {
|
||||
try {
|
||||
relevanceByTestIds.accept(ids, planId);
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<TestPlan> recentTestPlans(String projectId) {
|
||||
return extTestPlanMapper.listRecent(SessionUtils.getUserId(), projectId);
|
||||
}
|
||||
@ -908,6 +894,7 @@ public class TestPlanService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将测试计划运行时的triggerMode转化为性能测试中辨别更明确的值
|
||||
*
|
||||
@ -1145,12 +1132,6 @@ public class TestPlanService {
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
|
||||
try {
|
||||
planTestPlanApiCaseService.copyPlan(sourcePlanId, targetPlanId);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
|
||||
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
|
||||
|
||||
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
|
||||
@ -1269,11 +1250,9 @@ public class TestPlanService {
|
||||
request.setConfig(config);
|
||||
request.setPlanId(planId);
|
||||
request.setSaveResponse(saveResponse);
|
||||
try {
|
||||
if (DiscoveryUtil.hasService(MicroServiceName.API_TEST)) {
|
||||
ApiPlanReportDTO apiReport = planTestPlanScenarioCaseService.getApiReport(request);
|
||||
BeanUtils.copyBean(report, apiReport);
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1282,11 +1261,9 @@ public class TestPlanService {
|
||||
request.setConfig(config);
|
||||
request.setPlanId(planId);
|
||||
request.setSaveResponse(saveResponse);
|
||||
try {
|
||||
if (DiscoveryUtil.hasService(MicroServiceName.PERFORMANCE_TEST)) {
|
||||
LoadPlanReportDTO loadPlanReport = planTestPlanLoadCaseService.getLoadReport(request);
|
||||
BeanUtils.copyBean(report, loadPlanReport);
|
||||
} catch (MSException e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1562,11 +1539,11 @@ public class TestPlanService {
|
||||
.flatMap(Collection::stream)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(result)){
|
||||
if (CollectionUtils.isNotEmpty(result)) {
|
||||
envMap.put(projectId, result);
|
||||
}
|
||||
} else {
|
||||
if (CollectionUtils.isNotEmpty(scenarioEnv.get(projectId))){
|
||||
if (CollectionUtils.isNotEmpty(scenarioEnv.get(projectId))) {
|
||||
envMap.put(projectId, scenarioEnv.get(projectId));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user