fix(测试计划): 修复测试计划获取没有步骤结果场景时不会处理报告记录的问题
修复测试计划获取没有步骤结果场景时不会处理报告记录的问题
This commit is contained in:
parent
b7cd21bc4a
commit
75e678fc87
|
@ -1481,7 +1481,7 @@ public class ApiAutomationService {
|
||||||
String testId = executeQueue.get(reportId).getTestId();
|
String testId = executeQueue.get(reportId).getTestId();
|
||||||
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(executeQueue.get(reportId).getTestId())) {
|
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(executeQueue.get(reportId).getTestId())) {
|
||||||
testPlanScenarioId = executeQueue.get(reportId).getTestId();
|
testPlanScenarioId = executeQueue.get(reportId).getTestId();
|
||||||
testId = request.getScenarioTestPlanIdMap().get(executeQueue.get(reportId).getTestId());
|
testId = reportId;
|
||||||
} else {
|
} else {
|
||||||
testPlanScenarioId = request.getPlanScenarioId();
|
testPlanScenarioId = request.getPlanScenarioId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,14 +292,13 @@ public class ApiScenarioReportService {
|
||||||
scenario.setExecuteTimes(executeTimes + 1);
|
scenario.setExecuteTimes(executeTimes + 1);
|
||||||
|
|
||||||
apiScenarioMapper.updateByPrimaryKey(scenario);
|
apiScenarioMapper.updateByPrimaryKey(scenario);
|
||||||
// 发送通知
|
|
||||||
// sendNotice(scenario);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
returnReport = report;
|
returnReport = report;
|
||||||
reportIds.add(report.getId());
|
reportIds.add(report.getId());
|
||||||
MessageCache.executionQueue.remove(report.getId());
|
MessageCache.executionQueue.remove(report.getId());
|
||||||
}
|
}
|
||||||
|
counterPlanScenarioReport(result);
|
||||||
return returnReport;
|
return returnReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,6 +425,8 @@ public class ApiScenarioReportService {
|
||||||
LogUtil.error("未获取到场景报告。 报告ID:" + scenarioResult.getName() + "。 步骤信息:" + JSON.toJSONString(scenarioResult));
|
LogUtil.error("未获取到场景报告。 报告ID:" + scenarioResult.getName() + "。 步骤信息:" + JSON.toJSONString(scenarioResult));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 针对未正常返回结果的报告计数
|
||||||
|
counterPlanScenarioReport(result);
|
||||||
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(testPlanReportIdList) + " EXECUTE OVER. SCENARIO STATUS : " + JSONObject.toJSONString(scenarioAndErrorMap));
|
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(testPlanReportIdList) + " EXECUTE OVER. SCENARIO STATUS : " + JSONObject.toJSONString(scenarioAndErrorMap));
|
||||||
for (String reportId : testPlanReportIdList) {
|
for (String reportId : testPlanReportIdList) {
|
||||||
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(reportId, null, scenarioAndErrorMap, null);
|
TestPlanReportExecuteCatch.updateApiTestPlanExecuteInfo(reportId, null, scenarioAndErrorMap, null);
|
||||||
|
@ -577,6 +578,33 @@ public class ApiScenarioReportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void counterPlanScenarioReport(TestResult result) {
|
||||||
|
if (CollectionUtils.isEmpty(result.getScenarios()) && StringUtils.isNotEmpty(result.getTestId())) {
|
||||||
|
List<String> list = new LinkedList<>();
|
||||||
|
try {
|
||||||
|
list = JSON.parseObject(result.getTestId(), List.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
list.add(result.getTestId());
|
||||||
|
}
|
||||||
|
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(result.getTestId());
|
||||||
|
|
||||||
|
if (report != null) {
|
||||||
|
report.setStatus("Error");
|
||||||
|
apiScenarioReportMapper.updateByPrimaryKey(report);
|
||||||
|
MessageCache.scenarioExecResourceLock.remove(report.getId());
|
||||||
|
MessageCache.executionQueue.remove(report.getId());
|
||||||
|
if (StringUtils.equals(report.getExecuteType(), ExecuteType.Marge.name()) || StringUtils.equals(report.getScenarioId(), result.getSetReportId())) {
|
||||||
|
Object obj = MessageCache.cache.get(result.getSetReportId());
|
||||||
|
if (obj != null) {
|
||||||
|
ReportCounter counter = (ReportCounter) obj;
|
||||||
|
counter.getCompletedIds().add(report.getId());
|
||||||
|
MessageCache.cache.put(result.getSetReportId(), counter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ApiScenarioReport updateScenario(TestResult result) {
|
public ApiScenarioReport updateScenario(TestResult result) {
|
||||||
ApiScenarioReport lastReport = null;
|
ApiScenarioReport lastReport = null;
|
||||||
for (ScenarioResult item : result.getScenarios()) {
|
for (ScenarioResult item : result.getScenarios()) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
|
||||||
}else {
|
}else {
|
||||||
reportId = runModeDataDTO.getTestId();
|
reportId = runModeDataDTO.getTestId();
|
||||||
}
|
}
|
||||||
jMeterService.runTest(runModeDataDTO.getTestId(), reportId, request.getRunMode(), testPlanScenarioId, request.getConfig());
|
jMeterService.runTest(runModeDataDTO.getReport().getId(), reportId, request.getRunMode(), testPlanScenarioId, request.getConfig());
|
||||||
} else {
|
} else {
|
||||||
reportId = runModeDataDTO.getReport().getId();
|
reportId = runModeDataDTO.getReport().getId();
|
||||||
jMeterService.runLocal(runModeDataDTO.getReport().getId(),request.getConfig(), runModeDataDTO.getHashTree(), TriggerMode.BATCH.name().equals(request.getTriggerMode()) ? TriggerMode.BATCH.name() : request.getReportId(), request.getRunMode());
|
jMeterService.runLocal(runModeDataDTO.getReport().getId(),request.getConfig(), runModeDataDTO.getHashTree(), TriggerMode.BATCH.name().equals(request.getTriggerMode()) ? TriggerMode.BATCH.name() : request.getReportId(), request.getRunMode());
|
||||||
|
|
Loading…
Reference in New Issue