fix(接口测试): 修复串行同步锁失效问题

This commit is contained in:
fit2-zhao 2021-11-08 10:48:45 +08:00 committed by fit2-zhao
parent e4d67420f5
commit 723b8b745a
2 changed files with 12 additions and 7 deletions

View File

@ -289,6 +289,7 @@ public class ApiScenarioReportService {
} }
returnReport = report; returnReport = report;
reportIds.add(report.getId()); reportIds.add(report.getId());
MessageCache.executionQueue.remove(report.getId());
} }
return returnReport; return returnReport;
} }
@ -394,8 +395,7 @@ public class ApiScenarioReportService {
lastReport = report; lastReport = report;
APIScenarioReportResult reportResult = this.get(report.getId()); MessageCache.executionQueue.remove(report.getId());
// caseReportMap.put(testPlanApiScenario.getApiScenarioId(), reportResult);
reportIds.add(report.getId()); reportIds.add(report.getId());
} }
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));
@ -600,6 +600,7 @@ public class ApiScenarioReportService {
sendNotice(scenario, report); sendNotice(scenario, report);
} }
lastReport = report; lastReport = report;
MessageCache.executionQueue.remove(report.getId());
if (report.getExecuteType().equals(ExecuteType.Marge.name())) { if (report.getExecuteType().equals(ExecuteType.Marge.name())) {
Object obj = MessageCache.cache.get(report.getScenarioId()); Object obj = MessageCache.cache.get(report.getScenarioId());
if (obj != null) { if (obj != null) {

View File

@ -37,7 +37,7 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
MessageCache.terminationOrderDeque.remove(runModeDataDTO.getReport().getId()); MessageCache.terminationOrderDeque.remove(runModeDataDTO.getReport().getId());
return null; return null;
} }
String testId; String reportId;
if (request.getConfig() != null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) { if (request.getConfig() != null && StringUtils.isNotBlank(request.getConfig().getResourcePoolId())) {
String testPlanScenarioId = ""; String testPlanScenarioId = "";
if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(runModeDataDTO.getTestId())) { if (request.getScenarioTestPlanIdMap() != null && request.getScenarioTestPlanIdMap().containsKey(runModeDataDTO.getTestId())) {
@ -45,13 +45,17 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
} else { } else {
testPlanScenarioId = request.getPlanScenarioId(); testPlanScenarioId = request.getPlanScenarioId();
} }
testId = runModeDataDTO.getTestId(); if(runModeDataDTO.getReport()!= null){
jMeterService.runTest(runModeDataDTO.getTestId(), runModeDataDTO.getReport().getId(), request.getRunMode(), testPlanScenarioId, request.getConfig()); reportId = runModeDataDTO.getReport().getId();
}else {
reportId = runModeDataDTO.getTestId();
}
jMeterService.runTest(runModeDataDTO.getTestId(), reportId, request.getRunMode(), testPlanScenarioId, request.getConfig());
} else { } else {
testId = runModeDataDTO.getReport().getId(); reportId = runModeDataDTO.getReport().getId();
jMeterService.runLocal(runModeDataDTO.getReport().getId(), runModeDataDTO.getHashTree(), TriggerMode.BATCH.name().equals(request.getTriggerMode()) ? TriggerMode.BATCH.name() : request.getReportId(), request.getRunMode()); jMeterService.runLocal(runModeDataDTO.getReport().getId(), runModeDataDTO.getHashTree(), TriggerMode.BATCH.name().equals(request.getTriggerMode()) ? TriggerMode.BATCH.name() : request.getReportId(), request.getRunMode());
} }
while (MessageCache.executionQueue.containsKey(testId)) { while (MessageCache.executionQueue.containsKey(reportId)) {
long time = MessageCache.executionQueue.get(runModeDataDTO.getReport().getId()); long time = MessageCache.executionQueue.get(runModeDataDTO.getReport().getId());
long currentSecond = (System.currentTimeMillis() - time) / 1000 / 60; long currentSecond = (System.currentTimeMillis() - time) / 1000 / 60;
// 设置五分钟超时 // 设置五分钟超时