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