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;
reportIds.add(report.getId());
MessageCache.executionQueue.remove(report.getId());
}
return returnReport;
}
@ -394,8 +395,7 @@ public class ApiScenarioReportService {
lastReport = report;
APIScenarioReportResult reportResult = this.get(report.getId());
// caseReportMap.put(testPlanApiScenario.getApiScenarioId(), reportResult);
MessageCache.executionQueue.remove(report.getId());
reportIds.add(report.getId());
}
testPlanLog.info("TestPlanReportId" + JSONArray.toJSONString(testPlanReportIdList) + " EXECUTE OVER. SCENARIO STATUS : " + JSONObject.toJSONString(scenarioAndErrorMap));
@ -600,6 +600,7 @@ public class ApiScenarioReportService {
sendNotice(scenario, report);
}
lastReport = report;
MessageCache.executionQueue.remove(report.getId());
if (report.getExecuteType().equals(ExecuteType.Marge.name())) {
Object obj = MessageCache.cache.get(report.getScenarioId());
if (obj != null) {

View File

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