From ad06b74256c7d0a9abd6d80c29a9122ca3197540 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 17 Nov 2022 15:16:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E7=A6=81=E7=94=A8=E6=9C=AC=E5=9C=B0=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E6=A0=A1=E9=AA=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/jmeter/JMeterService.java | 27 +++++-------------- .../api/service/ApiPoolDebugService.java | 3 +++ .../plan/service/TestPlanService.java | 14 +++------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java index bbecf20ec5..83f6c973ff 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java @@ -15,13 +15,13 @@ import io.metersphere.commons.utils.*; import io.metersphere.config.JmeterProperties; import io.metersphere.constants.BackendListenerConstants; import io.metersphere.constants.RunModeConstants; -import io.metersphere.dto.*; +import io.metersphere.dto.JmeterRunRequestDTO; +import io.metersphere.dto.NodeDTO; +import io.metersphere.dto.RunModeConfigDTO; import io.metersphere.engine.Engine; import io.metersphere.jmeter.JMeterBase; import io.metersphere.jmeter.LocalRunner; -import io.metersphere.service.BaseProjectApplicationService; import io.metersphere.service.RemakeReportService; -import io.metersphere.service.SystemParameterService; import io.metersphere.utils.LoggerUtil; import io.metersphere.xpack.api.service.ApiPoolDebugService; import org.apache.commons.collections.CollectionUtils; @@ -56,10 +56,6 @@ public class JMeterService { @Resource private RedisTemplate redisTemplate; @Resource - private SystemParameterService systemParameterService; - @Resource - private BaseProjectApplicationService projectApplicationService; - @Resource private RemakeReportService remakeReportService; @Resource private ExecThreadPoolExecutor execThreadPoolExecutor; @@ -254,19 +250,10 @@ public class JMeterService { } } - public void verifyPool(String projectId, RunModeConfigDTO runConfig) { - // 检查是否禁用了本地执行 - if (runConfig != null && StringUtils.isEmpty(runConfig.getResourcePoolId()) - && CommonBeanFactory.getBean(ApiPoolDebugService.class) != null) { - BaseSystemConfigDTO configDTO = systemParameterService.getBaseInfo(); - if (StringUtils.equals(configDTO.getRunMode(), POOL)) { - ProjectConfig config = projectApplicationService.getProjectConfig(projectId); - if (config == null || !config.getPoolEnable() || StringUtils.isEmpty(config.getResourcePoolId())) { - MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池"); - } - runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig; - runConfig.setResourcePoolId(config.getResourcePoolId()); - } + public void verifyPool(String projectId, RunModeConfigDTO runModeConfigDTO) { + ApiPoolDebugService debugService = CommonBeanFactory.getBean(ApiPoolDebugService.class); + if (debugService != null) { + debugService.verifyPool(projectId, runModeConfigDTO); } } } diff --git a/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/api/service/ApiPoolDebugService.java b/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/api/service/ApiPoolDebugService.java index 92d9c15a9e..04ddeb96bf 100644 --- a/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/api/service/ApiPoolDebugService.java +++ b/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/api/service/ApiPoolDebugService.java @@ -2,9 +2,12 @@ package io.metersphere.xpack.api.service; import io.metersphere.base.domain.TestResource; import io.metersphere.dto.JmeterRunRequestDTO; +import io.metersphere.dto.RunModeConfigDTO; import java.util.List; public interface ApiPoolDebugService { public void run(JmeterRunRequestDTO request, List resources); + + public void verifyPool(String projectId, RunModeConfigDTO runConfig); } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index 91729c0b0c..0f30c15917 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -47,6 +47,7 @@ import io.metersphere.request.ScheduleRequest; import io.metersphere.service.*; import io.metersphere.utils.DiscoveryUtil; import io.metersphere.utils.LoggerUtil; +import io.metersphere.xpack.api.service.ApiPoolDebugService; import io.metersphere.xpack.track.dto.IssuesDao; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; @@ -889,16 +890,9 @@ public class TestPlanService { public void verifyPool(String projectId, RunModeConfigDTO runConfig) { // 检查是否禁用了本地执行 - if (runConfig != null && StringUtils.isEmpty(runConfig.getResourcePoolId())) { - BaseSystemConfigDTO configDTO = systemParameterService.getBaseInfo(); - if (StringUtils.equals(configDTO.getRunMode(), POOL)) { - ProjectConfig config = projectApplicationService.getProjectConfig(projectId); - if (config == null || !config.getPoolEnable() || StringUtils.isEmpty(config.getResourcePoolId())) { - MSException.throwException("请在【项目设置-应用管理-接口测试】中选择资源池"); - } - runConfig = runConfig == null ? new RunModeConfigDTO() : runConfig; - runConfig.setResourcePoolId(config.getResourcePoolId()); - } + ApiPoolDebugService debugService = CommonBeanFactory.getBean(ApiPoolDebugService.class); + if (debugService != null) { + debugService.verifyPool(projectId, runConfig); } }