From 723b8b745a3f5b6c76661014dfc77df30cb5020c Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 8 Nov 2021 10:48:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=B2=E8=A1=8C=E5=90=8C=E6=AD=A5=E9=94=81?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiScenarioReportService.java | 5 +++-- .../api/service/task/SerialScenarioExecTask.java | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 446aed07d7..1592c1864d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -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) { diff --git a/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java b/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java index 4794f69beb..99c95ae55f 100644 --- a/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java +++ b/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java @@ -37,7 +37,7 @@ public class SerialScenarioExecTask implements Callable { 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 implements Callable { } 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; // 设置五分钟超时