From 49c1bd88166910dbb37306a7c52369c35831af7b Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 22 Sep 2021 20:21:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92)=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B9=B6=E5=8F=91=E6=89=A7=E8=A1=8C=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20--bug=3D1006849=20--user=3D=E8=B5=B5=E5=8B=87=20?= =?UTF-8?q?=E3=80=90=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E3=80=91-?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=89=A7=E8=A1=8C=E6=8E=A5=E5=8F=A3=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=A4=B1=E8=B4=A5=20https://www.tapd.cn/55049933/s/10?= =?UTF-8?q?49783?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/api/jmeter/LocalRunner.java | 7 +++++-- .../metersphere/track/service/TestPlanApiCaseService.java | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java b/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java index 9c5a42800f..b00915af00 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/LocalRunner.java @@ -1,6 +1,7 @@ package io.metersphere.api.jmeter; import io.metersphere.commons.utils.LogUtil; +import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.engine.JMeterEngineException; import org.apache.jmeter.engine.StandardJMeterEngine; import org.apache.jorphan.collections.HashTree; @@ -20,7 +21,9 @@ public class LocalRunner { engine.configure(jmxTree); try { engine.runTest(); - MessageCache.runningEngine.put(report, engine); + if (StringUtils.isNotEmpty(report)) { + MessageCache.runningEngine.put(report, engine); + } } catch (JMeterEngineException e) { engine.stopTest(true); } @@ -29,7 +32,7 @@ public class LocalRunner { public void stop(String report) { try { StandardJMeterEngine engine = MessageCache.runningEngine.get(report); - if (engine != null) { + if (engine != null && StringUtils.isNotEmpty(report)) { engine.stopTest(); MessageCache.runningEngine.remove(report); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java index 1971ec0367..8dbaabbf84 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java @@ -480,9 +480,9 @@ public class TestPlanApiCaseService { ApiDefinitionExecResult report = addResult(request, key, APITestStatus.Running.name(), batchMapper); modeDataDTO.setApiCaseId(report.getId()); if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) { - jMeterService.runTest(modeDataDTO.getTestId(), modeDataDTO.getApiCaseId(), ApiRunMode.API_PLAN.name(), null, request.getConfig()); + jMeterService.runTest(report.getId(), modeDataDTO.getApiCaseId(), ApiRunMode.API_PLAN.name(), null, request.getConfig()); } else { - jMeterService.runLocal(modeDataDTO.getTestId(), modeDataDTO.getHashTree(), TriggerMode.BATCH.name() , ApiRunMode.API_PLAN.name()); + jMeterService.runLocal(report.getId(), modeDataDTO.getHashTree(), TriggerMode.BATCH.name() , ApiRunMode.API_PLAN.name()); } } sqlSession.flushStatements();