From a3561988b06dea3d131307a0396195a7ce6a057a Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 28 Oct 2021 10:46:40 +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=8Dk8s=E6=89=A7=E8=A1=8C=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/jmeter/JMeterService.java | 3 --- .../api/jmeter/ResourcePoolCalculation.java | 2 +- .../api/service/ApiAutomationService.java | 17 ++++++++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java b/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java index 445397e32a..b0204397ad 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/JMeterService.java @@ -31,7 +31,6 @@ import org.apache.jmeter.visualizers.backend.BackendListener; import org.apache.jorphan.collections.HashTree; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.http.ResponseEntity; -import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.RestTemplate; @@ -51,8 +50,6 @@ public class JMeterService { @Resource private TestResourcePoolMapper testResourcePoolMapper; @Resource - private KafkaTemplate kafkaTemplate; - @Resource private RestTemplate restTemplate; @PostConstruct diff --git a/backend/src/main/java/io/metersphere/api/jmeter/ResourcePoolCalculation.java b/backend/src/main/java/io/metersphere/api/jmeter/ResourcePoolCalculation.java index f62042ae3b..c1e8ff7eff 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/ResourcePoolCalculation.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/ResourcePoolCalculation.java @@ -78,7 +78,7 @@ public class ResourcePoolCalculation { public List getPools(String resourcePoolId) { // 获取可以执行的资源池 TestResourcePoolExample example = new TestResourcePoolExample(); - example.createCriteria().andStatusEqualTo("VALID").andIdEqualTo(resourcePoolId); + example.createCriteria().andStatusEqualTo("VALID").andTypeEqualTo("NODE").andIdEqualTo(resourcePoolId); List pools = testResourcePoolMapper.selectByExample(example); // 按照NODE节点的可用内存空间大小排序 diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 81c0655226..6febfcf1e6 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -144,6 +144,8 @@ public class ApiAutomationService { private RelationshipEdgeService relationshipEdgeService; @Resource private ApiScenarioFollowMapper apiScenarioFollowMapper; + @Resource + private TestResourcePoolMapper testResourcePoolMapper; private ThreadLocal currentScenarioOrder = new ThreadLocal<>(); @@ -1058,11 +1060,16 @@ public class ApiAutomationService { } // 资源池 if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) { - List testResources = resourcePoolCalculation.getPools(request.getConfig().getResourcePoolId()); - request.getConfig().setTestResources(testResources); - String status = nodeKafkaService.createKafkaProducer(request.getConfig()); - if ("ERROR".equals(status)) { - MSException.throwException("执行节点的kafka 启动失败,无法执行"); + TestResourcePool pool = testResourcePoolMapper.selectByPrimaryKey(request.getConfig().getResourcePoolId()); + if (pool != null && pool.getApi() && pool.getType().equals(ResourcePoolTypeEnum.K8S.name())) { + LogUtil.info("K8S 暂时不做校验 "); + } else { + List testResources = resourcePoolCalculation.getPools(request.getConfig().getResourcePoolId()); + request.getConfig().setTestResources(testResources); + String status = nodeKafkaService.createKafkaProducer(request.getConfig()); + if ("ERROR".equals(status)) { + MSException.throwException("执行节点的kafka 启动失败,无法执行"); + } } } // 环境检查