fix(接口测试): 修复k8s执行环境校验问题修复

This commit is contained in:
fit2-zhao 2021-10-28 10:46:40 +08:00 committed by fit2-zhao
parent e9641c5483
commit a3561988b0
3 changed files with 13 additions and 9 deletions

View File

@ -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<String, Object> kafkaTemplate;
@Resource
private RestTemplate restTemplate;
@PostConstruct

View File

@ -78,7 +78,7 @@ public class ResourcePoolCalculation {
public List<JvmInfoDTO> getPools(String resourcePoolId) {
// 获取可以执行的资源池
TestResourcePoolExample example = new TestResourcePoolExample();
example.createCriteria().andStatusEqualTo("VALID").andIdEqualTo(resourcePoolId);
example.createCriteria().andStatusEqualTo("VALID").andTypeEqualTo("NODE").andIdEqualTo(resourcePoolId);
List<TestResourcePool> pools = testResourcePoolMapper.selectByExample(example);
// 按照NODE节点的可用内存空间大小排序

View File

@ -144,6 +144,8 @@ public class ApiAutomationService {
private RelationshipEdgeService relationshipEdgeService;
@Resource
private ApiScenarioFollowMapper apiScenarioFollowMapper;
@Resource
private TestResourcePoolMapper testResourcePoolMapper;
private ThreadLocal<Long> currentScenarioOrder = new ThreadLocal<>();
@ -1058,6 +1060,10 @@ public class ApiAutomationService {
}
// 资源池
if (request.getConfig() != null && StringUtils.isNotEmpty(request.getConfig().getResourcePoolId())) {
TestResourcePool pool = testResourcePoolMapper.selectByPrimaryKey(request.getConfig().getResourcePoolId());
if (pool != null && pool.getApi() && pool.getType().equals(ResourcePoolTypeEnum.K8S.name())) {
LogUtil.info("K8S 暂时不做校验 ");
} else {
List<JvmInfoDTO> testResources = resourcePoolCalculation.getPools(request.getConfig().getResourcePoolId());
request.getConfig().setTestResources(testResources);
String status = nodeKafkaService.createKafkaProducer(request.getConfig());
@ -1065,6 +1071,7 @@ public class ApiAutomationService {
MSException.throwException("执行节点的kafka 启动失败,无法执行");
}
}
}
// 环境检查
this.checkEnv(request, apiScenarios);
// 集合报告设置