fix(接口测试): 生成测试数据问题修复
--bug=1017873 --user=赵勇 【接口测试】接口定义-json-schema,预览显示了默认值,并且默认值带了引号 https://www.tapd.cn/55049933/s/1259972
This commit is contained in:
parent
6c7bd5723a
commit
079b569742
|
@ -6,7 +6,7 @@ import io.metersphere.commons.constants.ResourcePoolTypeEnum;
|
|||
import io.metersphere.commons.constants.ResourceStatusEnum;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.config.JmeterProperties;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.engine.Engine;
|
||||
import io.metersphere.service.BaseTestResourcePoolService;
|
||||
|
@ -17,9 +17,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import java.util.List;
|
||||
|
||||
public abstract class AbstractEngine implements Engine {
|
||||
protected String JMETER_IMAGE;
|
||||
protected String HEAP;
|
||||
protected String GC_ALGO;
|
||||
protected List<TestResource> resourceList;
|
||||
protected TestResourcePool resourcePool;
|
||||
private final BaseTestResourcePoolService testResourcePoolService;
|
||||
|
@ -28,12 +25,10 @@ public abstract class AbstractEngine implements Engine {
|
|||
public AbstractEngine() {
|
||||
testResourcePoolService = CommonBeanFactory.getBean(BaseTestResourcePoolService.class);
|
||||
testResourceService = CommonBeanFactory.getBean(BaseTestResourceService.class);
|
||||
JMETER_IMAGE = CommonBeanFactory.getBean(JmeterProperties.class).getImage();
|
||||
HEAP = CommonBeanFactory.getBean(JmeterProperties.class).getHeap();
|
||||
GC_ALGO = CommonBeanFactory.getBean(JmeterProperties.class).getGcAlgo();
|
||||
}
|
||||
|
||||
protected void initApiConfig(JmeterRunRequestDTO runRequest) {
|
||||
LogUtil.info("初始化参数", runRequest.getReportId());
|
||||
String resourcePoolId = runRequest.getPoolId();
|
||||
resourcePool = testResourcePoolService.getResourcePool(resourcePoolId);
|
||||
if (resourcePool == null || StringUtils.equals(resourcePool.getStatus(), ResourceStatusEnum.DELETE.name())) {
|
||||
|
@ -46,24 +41,10 @@ public abstract class AbstractEngine implements Engine {
|
|||
if (!StringUtils.equals(resourcePool.getStatus(), ResourceStatusEnum.VALID.name())) {
|
||||
MSException.throwException("Resource Pool Status is not VALID");
|
||||
}
|
||||
// image
|
||||
String image = resourcePool.getImage();
|
||||
if (StringUtils.isNotEmpty(image)) {
|
||||
JMETER_IMAGE = image;
|
||||
}
|
||||
// heap
|
||||
String heap = resourcePool.getHeap();
|
||||
if (StringUtils.isNotEmpty(heap)) {
|
||||
HEAP = heap;
|
||||
}
|
||||
// gc_algo
|
||||
String gcAlgo = resourcePool.getGcAlgo();
|
||||
if (StringUtils.isNotEmpty(gcAlgo)) {
|
||||
GC_ALGO = gcAlgo;
|
||||
}
|
||||
this.resourceList = testResourceService.getResourcesByPoolId(resourcePool.getId());
|
||||
if (CollectionUtils.isEmpty(this.resourceList)) {
|
||||
MSException.throwException("Test Resource is empty");
|
||||
}
|
||||
LogUtil.info("初始化参数完成", runRequest.getReportId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.exec.engine;
|
||||
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.engine.Engine;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -9,6 +10,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public class EngineFactory {
|
||||
public static Engine createApiEngine(JmeterRunRequestDTO runRequest) {
|
||||
LogUtil.info("创建K8s client");
|
||||
return new KubernetesTestEngine(runRequest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.fabric8.kubernetes.client.KubernetesClient;
|
|||
import io.metersphere.base.domain.TestResource;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.xpack.resourcepool.engine.provider.ClientCredential;
|
||||
|
@ -35,6 +36,7 @@ public class KubernetesTestEngine extends AbstractEngine {
|
|||
|
||||
@Override
|
||||
public void start() {
|
||||
LogUtil.info("k8s 执行开始", resourceList.size());
|
||||
resourceList.forEach(r -> {
|
||||
runApi(r);
|
||||
});
|
||||
|
|
|
@ -80,7 +80,7 @@ public class JSONSchemaGenerator {
|
|||
}
|
||||
}
|
||||
if (object.has(PropertyConstant.DEFAULT)) {
|
||||
concept.put(propertyName, object.get(PropertyConstant.DEFAULT));
|
||||
concept.put(propertyName, object.get(PropertyConstant.DEFAULT).getAsString());
|
||||
} else if (object.has(PropertyConstant.ENUM)) {
|
||||
try {
|
||||
if (object.has(PropertyConstant.MOCK) && object.get(PropertyConstant.MOCK).getAsJsonObject() != null && StringUtils.isNotEmpty(object.get(PropertyConstant.MOCK).getAsJsonObject().get(PropertyConstant.MOCK).getAsString())) {
|
||||
|
|
|
@ -45,7 +45,7 @@ export default {
|
|||
appendToBody: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
width: {
|
||||
|
|
|
@ -966,6 +966,7 @@ export default {
|
|||
},
|
||||
handleProtocolChange(protocol) {
|
||||
this.initApiTableOpretion = "currentProtocol";
|
||||
this.selectNodeIds = [];
|
||||
this.currentProtocol = protocol;
|
||||
},
|
||||
setModuleOptions(data) {
|
||||
|
|
|
@ -131,7 +131,7 @@ export default {
|
|||
appendDialogToBody: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
isReadOnly: {
|
||||
|
|
|
@ -68,7 +68,7 @@ export default {
|
|||
appendToBody: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -135,9 +135,6 @@ export default {
|
|||
isRelevanceModel() {
|
||||
return this.relevanceProjectId ? true : false;
|
||||
},
|
||||
isReviewModel() {
|
||||
return this.reviewId ? true : false;
|
||||
},
|
||||
projectId() {
|
||||
if (this.selectProjectId) {
|
||||
return this.selectProjectId;
|
||||
|
|
Loading…
Reference in New Issue