refactor(接口测试): 兼容历史执行结果处理日志中出现异常问题#20236
This commit is contained in:
parent
cbe5f741e1
commit
aa5c66b8aa
|
@ -6,12 +6,10 @@ import io.metersphere.api.dto.scenario.HttpConfig;
|
||||||
import io.metersphere.api.dto.scenario.HttpConfigCondition;
|
import io.metersphere.api.dto.scenario.HttpConfigCondition;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.service.definition.ApiDefinitionService;
|
|
||||||
import io.metersphere.service.definition.ApiTestCaseService;
|
|
||||||
import io.metersphere.service.plan.TestPlanApiCaseService;
|
|
||||||
import io.metersphere.base.domain.ApiDefinition;
|
import io.metersphere.base.domain.ApiDefinition;
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
import io.metersphere.base.domain.TestPlanApiCase;
|
import io.metersphere.base.domain.TestPlanApiCase;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ConditionType;
|
import io.metersphere.commons.constants.ConditionType;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
|
@ -19,6 +17,9 @@ import io.metersphere.environment.ssl.MsKeyStore;
|
||||||
import io.metersphere.jmeter.utils.ScriptEngineUtils;
|
import io.metersphere.jmeter.utils.ScriptEngineUtils;
|
||||||
import io.metersphere.plugin.core.MsParameter;
|
import io.metersphere.plugin.core.MsParameter;
|
||||||
import io.metersphere.plugin.core.MsTestElement;
|
import io.metersphere.plugin.core.MsTestElement;
|
||||||
|
import io.metersphere.service.definition.ApiDefinitionService;
|
||||||
|
import io.metersphere.service.definition.ApiTestCaseService;
|
||||||
|
import io.metersphere.service.plan.TestPlanApiCaseService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -130,7 +131,7 @@ public class ParameterConfig extends MsParameter {
|
||||||
ApiDefinition apiDefinition = null;
|
ApiDefinition apiDefinition = null;
|
||||||
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
||||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||||
if (StringUtils.isNotEmpty(samplerProxy.getRefType()) && samplerProxy.getRefType().equals("CASE")) {
|
if (StringUtils.isNotEmpty(samplerProxy.getRefType()) && samplerProxy.getRefType().equals(CommonConstants.CASE)) {
|
||||||
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(samplerProxy.getId());
|
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(samplerProxy.getId());
|
||||||
if (caseWithBLOBs != null) {
|
if (caseWithBLOBs != null) {
|
||||||
apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId());
|
apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId());
|
||||||
|
|
|
@ -9,21 +9,22 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||||
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.service.definition.ApiDefinitionService;
|
|
||||||
import io.metersphere.service.definition.ApiTestCaseService;
|
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import io.metersphere.commons.utils.JSONUtil;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||||
import io.metersphere.plugin.core.MsParameter;
|
import io.metersphere.plugin.core.MsParameter;
|
||||||
import io.metersphere.plugin.core.MsTestElement;
|
import io.metersphere.plugin.core.MsTestElement;
|
||||||
import io.metersphere.commons.utils.JSONUtil;
|
import io.metersphere.service.definition.ApiDefinitionService;
|
||||||
|
import io.metersphere.service.definition.ApiTestCaseService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -183,7 +184,7 @@ public class MsJDBCPostProcessor extends MsTestElement {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
MsJDBCPostProcessor proxy = null;
|
MsJDBCPostProcessor proxy = null;
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
|
|
|
@ -9,22 +9,23 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||||
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.service.definition.ApiDefinitionService;
|
|
||||||
import io.metersphere.service.definition.ApiTestCaseService;
|
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.constants.RequestTypeConstants;
|
import io.metersphere.commons.constants.RequestTypeConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import io.metersphere.commons.utils.JSONUtil;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||||
import io.metersphere.plugin.core.MsParameter;
|
import io.metersphere.plugin.core.MsParameter;
|
||||||
import io.metersphere.plugin.core.MsTestElement;
|
import io.metersphere.plugin.core.MsTestElement;
|
||||||
import io.metersphere.commons.utils.JSONUtil;
|
import io.metersphere.service.definition.ApiDefinitionService;
|
||||||
|
import io.metersphere.service.definition.ApiTestCaseService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -47,7 +48,6 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
|
||||||
public class MsJDBCPreProcessor extends MsTestElement {
|
public class MsJDBCPreProcessor extends MsTestElement {
|
||||||
// type 必须放最前面,以便能够转换正确的类
|
// type 必须放最前面,以便能够转换正确的类
|
||||||
private String type = ElementConstants.JDBC_PRE;
|
private String type = ElementConstants.JDBC_PRE;
|
||||||
|
@ -172,7 +172,7 @@ public class MsJDBCPreProcessor extends MsTestElement {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
MsJDBCPreProcessor proxy = null;
|
MsJDBCPreProcessor proxy = null;
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
|
|
|
@ -17,17 +17,18 @@ import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
||||||
import io.metersphere.api.parse.api.JMeterScriptUtil;
|
import io.metersphere.api.parse.api.JMeterScriptUtil;
|
||||||
import io.metersphere.service.definition.ApiDefinitionService;
|
|
||||||
import io.metersphere.service.definition.ApiTestCaseService;
|
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import io.metersphere.commons.utils.JSONUtil;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.plugin.core.MsParameter;
|
import io.metersphere.plugin.core.MsParameter;
|
||||||
import io.metersphere.plugin.core.MsTestElement;
|
import io.metersphere.plugin.core.MsTestElement;
|
||||||
import io.metersphere.commons.utils.JSONUtil;
|
import io.metersphere.service.definition.ApiDefinitionService;
|
||||||
|
import io.metersphere.service.definition.ApiTestCaseService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -43,42 +44,24 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
|
||||||
public class MsDubboSampler extends MsTestElement {
|
public class MsDubboSampler extends MsTestElement {
|
||||||
private String clazzName = MsDubboSampler.class.getCanonicalName();
|
private String clazzName = MsDubboSampler.class.getCanonicalName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* type 必须放最前面,以便能够转换正确的类
|
* type 必须放最前面,以便能够转换正确的类
|
||||||
*/
|
*/
|
||||||
private String type = ElementConstants.DUBBO_SAMPLER;
|
private String type = ElementConstants.DUBBO_SAMPLER;
|
||||||
|
|
||||||
|
|
||||||
private final String protocol = "dubbo://";
|
private final String protocol = "dubbo://";
|
||||||
@JsonProperty(value = "interface")
|
@JsonProperty(value = "interface")
|
||||||
|
|
||||||
private String _interface;
|
private String _interface;
|
||||||
|
|
||||||
private String method;
|
private String method;
|
||||||
|
|
||||||
|
|
||||||
private MsConfigCenter configCenter;
|
private MsConfigCenter configCenter;
|
||||||
|
|
||||||
private MsRegistryCenter registryCenter;
|
private MsRegistryCenter registryCenter;
|
||||||
|
|
||||||
private MsConsumerAndService consumerAndService;
|
private MsConsumerAndService consumerAndService;
|
||||||
|
|
||||||
|
|
||||||
private List<KeyValue> args;
|
private List<KeyValue> args;
|
||||||
|
|
||||||
private List<KeyValue> attachmentArgs;
|
private List<KeyValue> attachmentArgs;
|
||||||
|
|
||||||
|
|
||||||
private String useEnvironment;
|
private String useEnvironment;
|
||||||
|
|
||||||
|
|
||||||
private boolean customizeReq;
|
private boolean customizeReq;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||||
ParameterConfig config = (ParameterConfig) msParameter;
|
ParameterConfig config = (ParameterConfig) msParameter;
|
||||||
|
@ -134,7 +117,7 @@ public class MsDubboSampler extends MsTestElement {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
MsDubboSampler proxy = null;
|
MsDubboSampler proxy = null;
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
|
@ -155,7 +138,7 @@ public class MsDubboSampler extends MsTestElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||||
} else {
|
} else {
|
||||||
this.setHashTree(proxy.getHashTree());
|
this.setHashTree(proxy.getHashTree());
|
||||||
|
|
|
@ -18,6 +18,7 @@ import io.metersphere.api.dto.scenario.environment.CommonConfig;
|
||||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.api.parse.api.JMeterScriptUtil;
|
import io.metersphere.api.parse.api.JMeterScriptUtil;
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
@ -82,6 +83,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
private Boolean isRefEnvironment;
|
private Boolean isRefEnvironment;
|
||||||
private String alias;
|
private String alias;
|
||||||
private boolean customizeReq;
|
private boolean customizeReq;
|
||||||
|
private final static String DEF_TIME_OUT = "60000";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||||
|
@ -134,8 +136,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
config.compatible(this);
|
config.compatible(this);
|
||||||
this.initConnectAndResponseTimeout(config);
|
this.initConnectAndResponseTimeout(config);
|
||||||
sampler.setConnectTimeout(this.getConnectTimeout() == null ? "60000" : this.getConnectTimeout());
|
sampler.setConnectTimeout(this.getConnectTimeout() == null ? DEF_TIME_OUT : this.getConnectTimeout());
|
||||||
sampler.setResponseTimeout(this.getResponseTimeout() == null ? "60000" : this.getResponseTimeout());
|
sampler.setResponseTimeout(this.getResponseTimeout() == null ? DEF_TIME_OUT : this.getResponseTimeout());
|
||||||
HttpConfig httpConfig = getHttpConfig(config);
|
HttpConfig httpConfig = getHttpConfig(config);
|
||||||
setSamplerPath(config, httpConfig, sampler);
|
setSamplerPath(config, httpConfig, sampler);
|
||||||
// 请求体处理
|
// 请求体处理
|
||||||
|
@ -246,7 +248,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
MsHTTPSamplerProxy proxy = null;
|
MsHTTPSamplerProxy proxy = null;
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ApiTestCaseWithBLOBs bloBs = CommonBeanFactory.getBean(ApiTestCaseService.class).get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = CommonBeanFactory.getBean(ApiTestCaseService.class).get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
this.setProjectId(bloBs.getProjectId());
|
this.setProjectId(bloBs.getProjectId());
|
||||||
|
@ -258,7 +260,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||||
} else {
|
} else {
|
||||||
this.setHashTree(proxy.getHashTree());
|
this.setHashTree(proxy.getHashTree());
|
||||||
|
@ -285,12 +287,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
CommonConfig commonConfig = config.getConfig().get(this.getProjectId()).getCommonConfig();
|
CommonConfig commonConfig = config.getConfig().get(this.getProjectId()).getCommonConfig();
|
||||||
if (commonConfig != null) {
|
if (commonConfig != null) {
|
||||||
if (this.getConnectTimeout() == null || StringUtils.equals(this.getConnectTimeout(), "60000")) {
|
if (this.getConnectTimeout() == null || StringUtils.equals(this.getConnectTimeout(), DEF_TIME_OUT)) {
|
||||||
if (commonConfig.getRequestTimeout() != 0) {
|
if (commonConfig.getRequestTimeout() != 0) {
|
||||||
this.setConnectTimeout(String.valueOf(commonConfig.getRequestTimeout()));
|
this.setConnectTimeout(String.valueOf(commonConfig.getRequestTimeout()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.getResponseTimeout() == null || StringUtils.equals(this.getResponseTimeout(), "60000")) {
|
if (this.getResponseTimeout() == null || StringUtils.equals(this.getResponseTimeout(), DEF_TIME_OUT)) {
|
||||||
if (commonConfig.getResponseTimeout() != 0) {
|
if (commonConfig.getResponseTimeout() != 0) {
|
||||||
this.setResponseTimeout(String.valueOf(commonConfig.getResponseTimeout()));
|
this.setResponseTimeout(String.valueOf(commonConfig.getResponseTimeout()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,29 +3,30 @@ package io.metersphere.api.dto.definition.request.sampler;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.metersphere.api.parse.api.JMeterScriptUtil;
|
|
||||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||||
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
import io.metersphere.api.dto.scenario.KeyValue;
|
||||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
||||||
import io.metersphere.service.definition.ApiDefinitionService;
|
import io.metersphere.api.parse.api.JMeterScriptUtil;
|
||||||
import io.metersphere.service.definition.ApiTestCaseService;
|
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import io.metersphere.commons.utils.HashTreeUtil;
|
||||||
|
import io.metersphere.commons.utils.JSONUtil;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||||
import io.metersphere.plugin.core.MsParameter;
|
import io.metersphere.plugin.core.MsParameter;
|
||||||
import io.metersphere.plugin.core.MsTestElement;
|
import io.metersphere.plugin.core.MsTestElement;
|
||||||
import io.metersphere.commons.utils.HashTreeUtil;
|
import io.metersphere.service.definition.ApiDefinitionService;
|
||||||
import io.metersphere.commons.utils.JSONUtil;
|
import io.metersphere.service.definition.ApiTestCaseService;
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -198,7 +199,7 @@ public class MsJDBCSampler extends MsTestElement {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
MsJDBCSampler proxy = null;
|
MsJDBCSampler proxy = null;
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
|
@ -219,7 +220,7 @@ public class MsJDBCSampler extends MsTestElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||||
} else {
|
} else {
|
||||||
this.setHashTree(proxy.getHashTree());
|
this.setHashTree(proxy.getHashTree());
|
||||||
|
|
|
@ -16,6 +16,7 @@ import io.metersphere.api.parse.api.JMeterScriptUtil;
|
||||||
import io.metersphere.api.parse.scenario.TcpTreeTableDataParser;
|
import io.metersphere.api.parse.scenario.TcpTreeTableDataParser;
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
@ -183,7 +184,7 @@ public class MsTCPSampler extends MsTestElement {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
MsTCPSampler proxy = null;
|
MsTCPSampler proxy = null;
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||||
if (bloBs != null) {
|
if (bloBs != null) {
|
||||||
|
@ -204,7 +205,7 @@ public class MsTCPSampler extends MsTestElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||||
} else {
|
} else {
|
||||||
this.setHashTree(proxy.getHashTree());
|
this.setHashTree(proxy.getHashTree());
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package io.metersphere.api.exec.api;
|
package io.metersphere.api.exec.api;
|
||||||
|
|
||||||
import io.metersphere.api.exec.queue.DBTestQueue;
|
import io.metersphere.api.exec.queue.DBTestQueue;
|
||||||
import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
|
||||||
import io.metersphere.api.jmeter.JMeterService;
|
import io.metersphere.api.jmeter.JMeterService;
|
||||||
import io.metersphere.api.jmeter.utils.SmoothWeighted;
|
import io.metersphere.api.jmeter.utils.SmoothWeighted;
|
||||||
import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
|
import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||||
|
@ -45,7 +46,7 @@ public class ApiCaseParallelExecuteService {
|
||||||
}
|
}
|
||||||
ApiDefinitionExecResultWithBLOBs result = executeQueue.get(testId);
|
ApiDefinitionExecResultWithBLOBs result = executeQueue.get(testId);
|
||||||
String reportId = result.getId();
|
String reportId = result.getId();
|
||||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testId, reportId, runMode, null);
|
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testId, reportId, runMode);
|
||||||
runRequest.setPool(pool);
|
runRequest.setPool(pool);
|
||||||
runRequest.setTestPlanReportId(executionQueue.getReportId());
|
runRequest.setTestPlanReportId(executionQueue.getReportId());
|
||||||
runRequest.setPoolId(config.getResourcePoolId());
|
runRequest.setPoolId(config.getResourcePoolId());
|
||||||
|
@ -57,7 +58,7 @@ public class ApiCaseParallelExecuteService {
|
||||||
runRequest.setRetryEnable(config.isRetryEnable());
|
runRequest.setRetryEnable(config.isRetryEnable());
|
||||||
|
|
||||||
Map<String, Object> extendedParameters = new HashMap<>();
|
Map<String, Object> extendedParameters = new HashMap<>();
|
||||||
extendedParameters.put("userId", result.getUserId());
|
extendedParameters.put(CommonConstants.USER_ID, result.getUserId());
|
||||||
runRequest.setExtendedParameters(extendedParameters);
|
runRequest.setExtendedParameters(extendedParameters);
|
||||||
if (MapUtils.isNotEmpty(executionQueue.getDetailMap())) {
|
if (MapUtils.isNotEmpty(executionQueue.getDetailMap())) {
|
||||||
runRequest.setPlatformUrl(GenerateHashTreeUtil.getPlatformUrl(baseInfo, runRequest, executionQueue.getDetailMap().get(result.getId())));
|
runRequest.setPlatformUrl(GenerateHashTreeUtil.getPlatformUrl(baseInfo, runRequest, executionQueue.getDetailMap().get(result.getId())));
|
||||||
|
|
|
@ -23,6 +23,7 @@ import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
|
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.PropertyConstant;
|
import io.metersphere.commons.constants.PropertyConstant;
|
||||||
import io.metersphere.commons.enums.ApiReportStatus;
|
import io.metersphere.commons.enums.ApiReportStatus;
|
||||||
|
@ -99,7 +100,7 @@ public class ApiCaseSerialService {
|
||||||
ApiDefinitionExecResultWithBLOBs execResult = apiDefinitionExecResultMapper.selectByPrimaryKey(queue.getReportId());
|
ApiDefinitionExecResultWithBLOBs execResult = apiDefinitionExecResultMapper.selectByPrimaryKey(queue.getReportId());
|
||||||
if (execResult != null) {
|
if (execResult != null) {
|
||||||
runRequest.setExtendedParameters(new HashMap<String, Object>() {{
|
runRequest.setExtendedParameters(new HashMap<String, Object>() {{
|
||||||
this.put("userId", execResult.getUserId());
|
this.put(CommonConstants.USER_ID, execResult.getUserId());
|
||||||
}});
|
}});
|
||||||
execResult.setStartTime(System.currentTimeMillis());
|
execResult.setStartTime(System.currentTimeMillis());
|
||||||
execResult.setStatus(ApiReportStatus.RUNNING.name());
|
execResult.setStatus(ApiReportStatus.RUNNING.name());
|
||||||
|
|
|
@ -22,6 +22,7 @@ import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
|
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.ExtendedParameter;
|
import io.metersphere.commons.constants.ExtendedParameter;
|
||||||
import io.metersphere.commons.enums.ApiReportStatus;
|
import io.metersphere.commons.enums.ApiReportStatus;
|
||||||
|
@ -254,7 +255,7 @@ public class ApiExecuteService {
|
||||||
runRequest.setRunMode(runMode);
|
runRequest.setRunMode(runMode);
|
||||||
runRequest.setExtendedParameters(new HashMap<String, Object>() {{
|
runRequest.setExtendedParameters(new HashMap<String, Object>() {{
|
||||||
this.put(ExtendedParameter.SYNC_STATUS, request.isSyncResult());
|
this.put(ExtendedParameter.SYNC_STATUS, request.isSyncResult());
|
||||||
this.put("userId", SessionUtils.getUser().getId());
|
this.put(CommonConstants.USER_ID, SessionUtils.getUser().getId());
|
||||||
this.put("userName", SessionUtils.getUser().getName());
|
this.put("userName", SessionUtils.getUser().getName());
|
||||||
}});
|
}});
|
||||||
if (CollectionUtils.isNotEmpty(projectIds)) {
|
if (CollectionUtils.isNotEmpty(projectIds)) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import io.metersphere.base.mapper.ApiTestEnvironmentMapper;
|
||||||
import io.metersphere.base.mapper.ProjectMapper;
|
import io.metersphere.base.mapper.ProjectMapper;
|
||||||
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
|
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
@ -32,7 +33,6 @@ import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.context.annotation.Lazy;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -53,7 +53,6 @@ public class ApiScenarioEnvService {
|
||||||
private ApiTestEnvironmentMapper apiTestEnvironmentMapper;
|
private ApiTestEnvironmentMapper apiTestEnvironmentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiTestCaseMapper apiTestCaseMapper;
|
private ApiTestCaseMapper apiTestCaseMapper;
|
||||||
@Lazy
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -99,7 +98,7 @@ public class ApiScenarioEnvService {
|
||||||
if (StringUtils.equals(testElement.getType(), ElementConstants.HTTP_SAMPLER)) {
|
if (StringUtils.equals(testElement.getType(), ElementConstants.HTTP_SAMPLER)) {
|
||||||
MsHTTPSamplerProxy http = (MsHTTPSamplerProxy) testElement;
|
MsHTTPSamplerProxy http = (MsHTTPSamplerProxy) testElement;
|
||||||
// 引用用例URL清空
|
// 引用用例URL清空
|
||||||
http.setUrl(StringUtils.equals(testElement.getRefType(), "CASE") ? null : http.getUrl());
|
http.setUrl(StringUtils.equals(testElement.getRefType(), CommonConstants.CASE) ? null : http.getUrl());
|
||||||
|
|
||||||
// 非全路径校验
|
// 非全路径校验
|
||||||
if (!StringUtils.equalsIgnoreCase(http.getReferenced(), "Created") || (http.getIsRefEnvironment() != null && http.getIsRefEnvironment())) {
|
if (!StringUtils.equalsIgnoreCase(http.getReferenced(), "Created") || (http.getIsRefEnvironment() != null && http.getIsRefEnvironment())) {
|
||||||
|
@ -108,7 +107,7 @@ public class ApiScenarioEnvService {
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equals(testElement.getType(), ElementConstants.JDBC_SAMPLER) || StringUtils.equals(testElement.getType(), ElementConstants.TCP_SAMPLER)) {
|
} else if (StringUtils.equals(testElement.getType(), ElementConstants.JDBC_SAMPLER) || StringUtils.equals(testElement.getType(), ElementConstants.TCP_SAMPLER)) {
|
||||||
if (StringUtils.isEmpty(testElement.getProjectId())) {
|
if (StringUtils.isEmpty(testElement.getProjectId())) {
|
||||||
if (StringUtils.equals(testElement.getRefType(), "CASE")) {
|
if (StringUtils.equals(testElement.getRefType(), CommonConstants.CASE)) {
|
||||||
ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(testElement.getId());
|
ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(testElement.getId());
|
||||||
if (testCase != null) {
|
if (testCase != null) {
|
||||||
env.getProjectIds().add(testCase.getProjectId());
|
env.getProjectIds().add(testCase.getProjectId());
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ApiScenarioParallelService {
|
||||||
|
|
||||||
protected JmeterRunRequestDTO getJmeterRunRequestDTO(RunScenarioRequest request, String serialReportId, DBTestQueue executionQueue,
|
protected JmeterRunRequestDTO getJmeterRunRequestDTO(RunScenarioRequest request, String serialReportId, DBTestQueue executionQueue,
|
||||||
BaseSystemConfigDTO baseInfo, String reportId, RunModeDataDTO dataDTO) {
|
BaseSystemConfigDTO baseInfo, String reportId, RunModeDataDTO dataDTO) {
|
||||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(dataDTO.getTestId(), StringUtils.isNotEmpty(serialReportId) ? serialReportId : reportId, request.getRunMode(), null);
|
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(dataDTO.getTestId(), StringUtils.isNotEmpty(serialReportId) ? serialReportId : reportId, request.getRunMode());
|
||||||
runRequest.setReportType(StringUtils.isNotEmpty(serialReportId) ? RunModeConstants.SET_REPORT.toString() : RunModeConstants.INDEPENDENCE.toString());
|
runRequest.setReportType(StringUtils.isNotEmpty(serialReportId) ? RunModeConstants.SET_REPORT.toString() : RunModeConstants.INDEPENDENCE.toString());
|
||||||
runRequest.setQueueId(executionQueue.getId());
|
runRequest.setQueueId(executionQueue.getId());
|
||||||
runRequest.setTestPlanReportId(request.getTestPlanReportId());
|
runRequest.setTestPlanReportId(request.getTestPlanReportId());
|
||||||
|
|
|
@ -12,14 +12,15 @@ import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||||
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
import io.metersphere.base.mapper.ApiScenarioReportMapper;
|
||||||
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
|
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.enums.ApiReportStatus;
|
import io.metersphere.commons.enums.ApiReportStatus;
|
||||||
import io.metersphere.commons.utils.JSON;
|
|
||||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
|
||||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
|
||||||
import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
||||||
import io.metersphere.commons.utils.HashTreeUtil;
|
import io.metersphere.commons.utils.HashTreeUtil;
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.commons.utils.JSON;
|
||||||
import io.metersphere.commons.utils.RequestParamsUtil;
|
import io.metersphere.commons.utils.RequestParamsUtil;
|
||||||
|
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||||
|
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||||
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
@ -123,7 +124,7 @@ public class ApiScenarioSerialService {
|
||||||
report.setCreateTime(System.currentTimeMillis());
|
report.setCreateTime(System.currentTimeMillis());
|
||||||
report.setUpdateTime(System.currentTimeMillis());
|
report.setUpdateTime(System.currentTimeMillis());
|
||||||
runRequest.setExtendedParameters(new HashMap<>() {{
|
runRequest.setExtendedParameters(new HashMap<>() {{
|
||||||
this.put("userId", report.getCreateUser());
|
this.put(CommonConstants.USER_ID, report.getCreateUser());
|
||||||
}});
|
}});
|
||||||
apiScenarioReportMapper.updateByPrimaryKey(report);
|
apiScenarioReportMapper.updateByPrimaryKey(report);
|
||||||
LoggerUtil.info("进入串行模式,准备执行资源:[ " + report.getName() + " ]", report.getId());
|
LoggerUtil.info("进入串行模式,准备执行资源:[ " + report.getName() + " ]", report.getId());
|
||||||
|
|
|
@ -3,10 +3,11 @@ package io.metersphere.api.jmeter;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil;
|
import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil;
|
||||||
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
|
import io.metersphere.commons.constants.ExtendedParameter;
|
||||||
|
import io.metersphere.dto.ResultDTO;
|
||||||
import io.metersphere.service.ApiExecutionQueueService;
|
import io.metersphere.service.ApiExecutionQueueService;
|
||||||
import io.metersphere.service.TestResultService;
|
import io.metersphere.service.TestResultService;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
|
||||||
import io.metersphere.dto.ResultDTO;
|
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -54,10 +55,10 @@ public class KafkaListenerTask implements Runnable {
|
||||||
if (dto == null) {
|
if (dto == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dto.getArbitraryData() != null && dto.getArbitraryData().containsKey("TEST_END")
|
if (dto.getArbitraryData() != null && dto.getArbitraryData().containsKey(ExtendedParameter.TEST_END)
|
||||||
&& (Boolean) dto.getArbitraryData().get("TEST_END")) {
|
&& (Boolean) dto.getArbitraryData().get(ExtendedParameter.TEST_END)) {
|
||||||
resultDTOS.add(dto);
|
resultDTOS.add(dto);
|
||||||
LoggerUtil.info("KAFKA消费结果处理状态:" + dto.getArbitraryData().get("TEST_END"), String.valueOf(record.key()));
|
LoggerUtil.info("KAFKA消费结果处理状态:" + dto.getArbitraryData().get(ExtendedParameter.TEST_END), String.valueOf(record.key()));
|
||||||
}
|
}
|
||||||
// 携带结果
|
// 携带结果
|
||||||
if (CollectionUtils.isNotEmpty(dto.getRequestResults())) {
|
if (CollectionUtils.isNotEmpty(dto.getRequestResults())) {
|
||||||
|
|
|
@ -162,6 +162,4 @@ public class MsApiBackendListener extends AbstractBackendListenerClient implemen
|
||||||
}
|
}
|
||||||
return reportId;
|
return reportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,7 @@ public class CommonConstants {
|
||||||
public static final String TRIGGER_MODE = "trigger_mode";
|
public static final String TRIGGER_MODE = "trigger_mode";
|
||||||
|
|
||||||
public static final String STATUS = "status";
|
public static final String STATUS = "status";
|
||||||
|
public static final String USER_ID = "userId";
|
||||||
|
public static final String METHODS_KEY = "methods";
|
||||||
|
public static final String CASE = "CASE";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,5 @@ public class ExtendedParameter {
|
||||||
public static final String SYNC_STATUS = "SYN_RES";
|
public static final String SYNC_STATUS = "SYN_RES";
|
||||||
public static final String SAVE_RESULT = "SAVE_RESULT";
|
public static final String SAVE_RESULT = "SAVE_RESULT";
|
||||||
public static final String PROJECT_ID = "projectId";
|
public static final String PROJECT_ID = "projectId";
|
||||||
|
public static final String TEST_END = "TEST_END";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import io.metersphere.utils.LoggerUtil;
|
||||||
public class RequestParamsUtil {
|
public class RequestParamsUtil {
|
||||||
|
|
||||||
public static JmeterRunRequestDTO init(ApiExecutionQueue executionQueue, ApiExecutionQueueDetail queue, String reportId) {
|
public static JmeterRunRequestDTO init(ApiExecutionQueue executionQueue, ApiExecutionQueueDetail queue, String reportId) {
|
||||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(queue.getTestId(), reportId, executionQueue.getRunMode(), null);
|
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(queue.getTestId(), reportId, executionQueue.getRunMode());
|
||||||
runRequest.setRetryEnable(queue.getRetryEnable() == null ? false : queue.getRetryEnable());
|
runRequest.setRetryEnable(queue.getRetryEnable() == null ? false : queue.getRetryEnable());
|
||||||
runRequest.setRetryNum(queue.getRetryNumber());
|
runRequest.setRetryNum(queue.getRetryNumber());
|
||||||
runRequest.setReportType(executionQueue.getReportType());
|
runRequest.setReportType(executionQueue.getReportType());
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ApiJMeterFileService {
|
||||||
|
|
||||||
public byte[] downloadJmeterFiles(String runMode, String remoteTestId, String reportId, String reportType, String queueId) {
|
public byte[] downloadJmeterFiles(String runMode, String remoteTestId, String reportId, String reportType, String queueId) {
|
||||||
Map<String, String> planEnvMap = new HashMap<>();
|
Map<String, String> planEnvMap = new HashMap<>();
|
||||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(remoteTestId, reportId, runMode, null);
|
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(remoteTestId, reportId, runMode);
|
||||||
runRequest.setReportType(reportType);
|
runRequest.setReportType(reportType);
|
||||||
runRequest.setQueueId(queueId);
|
runRequest.setQueueId(queueId);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.base.domain.Project;
|
||||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||||
import io.metersphere.base.mapper.ProjectMapper;
|
import io.metersphere.base.mapper.ProjectMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.PropertyConstant;
|
import io.metersphere.commons.constants.PropertyConstant;
|
||||||
import io.metersphere.commons.utils.JSON;
|
import io.metersphere.commons.utils.JSON;
|
||||||
|
@ -45,7 +46,7 @@ public class MsHashTreeService {
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectMapper projectMapper;
|
private ProjectMapper projectMapper;
|
||||||
|
|
||||||
public static final String CASE = "CASE";
|
public static final String CASE = CommonConstants.CASE;
|
||||||
public static final String REFERENCED = "referenced";
|
public static final String REFERENCED = "referenced";
|
||||||
public static final String REF = "REF";
|
public static final String REF = "REF";
|
||||||
public static final String COPY = "Copy";
|
public static final String COPY = "Copy";
|
||||||
|
@ -77,8 +78,8 @@ public class MsHashTreeService {
|
||||||
private static final String PRE = "PRE";
|
private static final String PRE = "PRE";
|
||||||
private static final String POST = "POST";
|
private static final String POST = "POST";
|
||||||
private static final String ASSERTIONS = ElementConstants.ASSERTIONS;
|
private static final String ASSERTIONS = ElementConstants.ASSERTIONS;
|
||||||
public static final String CUSTOMNUM = "customNum";
|
public static final String CUSTOM_NUM = "customNum";
|
||||||
public static final String SHOWCUSTOMNUM = "showCustomNum";
|
public static final String SHOW_CUSTOM_NUM = "showCustomNum";
|
||||||
|
|
||||||
public void setHashTree(JSONArray hashTree) {
|
public void setHashTree(JSONArray hashTree) {
|
||||||
// 将引用转成复制
|
// 将引用转成复制
|
||||||
|
@ -218,8 +219,8 @@ public class MsHashTreeService {
|
||||||
}
|
}
|
||||||
//获取场景的当前项目是否开启了自定义id
|
//获取场景的当前项目是否开启了自定义id
|
||||||
ProjectConfig projectApplication = baseProjectApplicationService.getSpecificTypeValue(scenarioWithBLOBs.getProjectId(), "SCENARIO_CUSTOM_NUM");
|
ProjectConfig projectApplication = baseProjectApplicationService.getSpecificTypeValue(scenarioWithBLOBs.getProjectId(), "SCENARIO_CUSTOM_NUM");
|
||||||
element.put(SHOWCUSTOMNUM, projectApplication.getScenarioCustomNum());
|
element.put(SHOW_CUSTOM_NUM, projectApplication.getScenarioCustomNum());
|
||||||
element.put(CUSTOMNUM, scenarioWithBLOBs.getCustomNum());
|
element.put(CUSTOM_NUM, scenarioWithBLOBs.getCustomNum());
|
||||||
this.setElement(element, scenarioWithBLOBs.getNum(), enable, scenarioWithBLOBs.getVersionName(), scenarioWithBLOBs.getVersionEnable());
|
this.setElement(element, scenarioWithBLOBs.getNum(), enable, scenarioWithBLOBs.getVersionName(), scenarioWithBLOBs.getVersionEnable());
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.equalsIgnoreCase(element.optString(REFERENCED), REF)) {
|
if (StringUtils.equalsIgnoreCase(element.optString(REFERENCED), REF)) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||||
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
|
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.NoticeConstants;
|
import io.metersphere.commons.constants.NoticeConstants;
|
||||||
import io.metersphere.commons.constants.TriggerMode;
|
import io.metersphere.commons.constants.TriggerMode;
|
||||||
import io.metersphere.commons.enums.ApiReportStatus;
|
import io.metersphere.commons.enums.ApiReportStatus;
|
||||||
|
@ -96,14 +97,14 @@ public class ApiDefinitionExecResultService {
|
||||||
apiExecutionInfoService.insertExecutionInfo(result);
|
apiExecutionInfoService.insertExecutionInfo(result);
|
||||||
User user = null;
|
User user = null;
|
||||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters())) {
|
if (MapUtils.isNotEmpty(dto.getExtendedParameters())) {
|
||||||
if (dto.getExtendedParameters().containsKey("userId") && dto.getExtendedParameters().containsKey("userName")) {
|
if (dto.getExtendedParameters().containsKey(CommonConstants.USER_ID) && dto.getExtendedParameters().containsKey("userName")) {
|
||||||
user = new User() {{
|
user = new User() {{
|
||||||
this.setId(dto.getExtendedParameters().get("userId").toString());
|
this.setId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
||||||
this.setName(dto.getExtendedParameters().get("userName").toString());
|
this.setName(dto.getExtendedParameters().get("userName").toString());
|
||||||
}};
|
}};
|
||||||
result.setUserId(user.getId());
|
result.setUserId(user.getId());
|
||||||
} else if (dto.getExtendedParameters().containsKey("userId")) {
|
} else if (dto.getExtendedParameters().containsKey(CommonConstants.USER_ID)) {
|
||||||
result.setUserId(dto.getExtendedParameters().get("userId").toString());
|
result.setUserId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//如果是测试计划用例,更新接口用例的上次执行结果
|
//如果是测试计划用例,更新接口用例的上次执行结果
|
||||||
|
@ -302,8 +303,8 @@ public class ApiDefinitionExecResultService {
|
||||||
LoggerUtil.info("执行结果【 " + item.getName() + " 】入库存储");
|
LoggerUtil.info("执行结果【 " + item.getName() + " 】入库存储");
|
||||||
if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
|
if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) {
|
||||||
ApiDefinitionExecResult reportResult = this.editResult(item, dto.getReportId(), dto.getConsole(), dto.getRunMode(), dto.getTestId(), null);
|
ApiDefinitionExecResult reportResult = this.editResult(item, dto.getReportId(), dto.getConsole(), dto.getRunMode(), dto.getTestId(), null);
|
||||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("userId")) {
|
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey(CommonConstants.USER_ID)) {
|
||||||
reportResult.setUserId(String.valueOf(dto.getExtendedParameters().get("userId")));
|
reportResult.setUserId(String.valueOf(dto.getExtendedParameters().get(CommonConstants.USER_ID)));
|
||||||
}
|
}
|
||||||
String triggerMode = StringUtils.EMPTY;
|
String triggerMode = StringUtils.EMPTY;
|
||||||
if (reportResult != null) {
|
if (reportResult != null) {
|
||||||
|
@ -402,7 +403,7 @@ public class ApiDefinitionExecResultService {
|
||||||
if (item.getStartTime() >= item.getEndTime()) {
|
if (item.getStartTime() >= item.getEndTime()) {
|
||||||
saveResult.setEndTime(System.currentTimeMillis());
|
saveResult.setEndTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(saveResult.getTriggerMode()) && saveResult.getTriggerMode().equals("CASE")) {
|
if (StringUtils.isNotEmpty(saveResult.getTriggerMode()) && saveResult.getTriggerMode().equals(CommonConstants.CASE)) {
|
||||||
saveResult.setTriggerMode(TriggerMode.MANUAL.name());
|
saveResult.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
}
|
}
|
||||||
if (batchMapper == null) {
|
if (batchMapper == null) {
|
||||||
|
|
|
@ -68,7 +68,6 @@ import org.apache.commons.collections4.comparators.FixedOrderComparator;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.dubbo.common.URL;
|
import org.apache.dubbo.common.URL;
|
||||||
import org.apache.dubbo.common.constants.CommonConstants;
|
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
@ -142,8 +141,6 @@ public class ApiDefinitionService {
|
||||||
private EsbApiParamsMapper esbApiParamsMapper;
|
private EsbApiParamsMapper esbApiParamsMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiExecutionInfoService apiExecutionInfoService;
|
private ApiExecutionInfoService apiExecutionInfoService;
|
||||||
@Resource
|
|
||||||
private ApiCaseExecutionInfoService apiCaseExecutionInfoService;
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Resource
|
@Resource
|
||||||
private ApiModuleService apiModuleService;
|
private ApiModuleService apiModuleService;
|
||||||
|
@ -1608,11 +1605,6 @@ public class ApiDefinitionService {
|
||||||
return buildAPIReportResult(result);
|
return buildAPIReportResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiReportResult getByResultId(String reportId) {
|
|
||||||
ApiDefinitionExecResultWithBLOBs result = apiDefinitionExecResultMapper.selectByPrimaryKey(reportId);
|
|
||||||
return buildAPIReportResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApiReportResult getReportById(String testId) {
|
public ApiReportResult getReportById(String testId) {
|
||||||
ApiDefinitionExecResultWithBLOBs result = apiDefinitionExecResultMapper.selectByPrimaryKey(testId);
|
ApiDefinitionExecResultWithBLOBs result = apiDefinitionExecResultMapper.selectByPrimaryKey(testId);
|
||||||
return buildAPIReportResult(result);
|
return buildAPIReportResult(result);
|
||||||
|
@ -1626,12 +1618,14 @@ public class ApiDefinitionService {
|
||||||
reportResult.setStatus(result.getStatus());
|
reportResult.setStatus(result.getStatus());
|
||||||
String contentStr = result.getContent();
|
String contentStr = result.getContent();
|
||||||
try {
|
try {
|
||||||
JSONObject content = JSONUtil.parseObject(result.getContent());
|
if (StringUtils.isNotBlank(contentStr)) {
|
||||||
if (StringUtils.isNotEmpty(result.getEnvConfig())) {
|
JSONObject content = JSONUtil.parseObject(contentStr);
|
||||||
content.put("envName", this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()));
|
if (StringUtils.isNotEmpty(result.getEnvConfig())) {
|
||||||
|
content.put("envName", this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()));
|
||||||
|
}
|
||||||
|
contentStr = content.toString();
|
||||||
|
reportResult.setContent(contentStr);
|
||||||
}
|
}
|
||||||
contentStr = content.toString();
|
|
||||||
reportResult.setContent(contentStr);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error("解析content失败!", e);
|
LogUtil.error("解析content失败!", e);
|
||||||
}
|
}
|
||||||
|
@ -2495,7 +2489,7 @@ public class ApiDefinitionService {
|
||||||
});
|
});
|
||||||
} else if (StringUtils.isNotEmpty(request.getUserId())) {
|
} else if (StringUtils.isNotEmpty(request.getUserId())) {
|
||||||
definitions.forEach(item -> {
|
definitions.forEach(item -> {
|
||||||
DetailColumn column = new DetailColumn(DefinitionReference.definitionColumns.get("userId"), "userId", item.getUserId(), null);
|
DetailColumn column = new DetailColumn(DefinitionReference.definitionColumns.get(CommonConstants.USER_ID), CommonConstants.USER_ID, item.getUserId(), null);
|
||||||
columns.add(column);
|
columns.add(column);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2521,26 +2515,11 @@ public class ApiDefinitionService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiDefinition selectUrlAndMethodById(String id) {
|
|
||||||
return extApiDefinitionMapper.selectUrlAndMethodById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeToGcByExample(ApiDefinitionExampleWithOperation apiDefinitionExample) {
|
|
||||||
List<ApiDefinition> apiList = apiDefinitionMapper.selectByExample(apiDefinitionExample);
|
|
||||||
List<String> apiIdList = new ArrayList<>();
|
|
||||||
apiList.forEach(item -> apiIdList.add(item.getId()));
|
|
||||||
this.removeToGc(apiIdList);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApiReportResult getTestPlanApiCaseReport(String testId, String type) {
|
public ApiReportResult getTestPlanApiCaseReport(String testId, String type) {
|
||||||
ApiDefinitionExecResultWithBLOBs result = extApiDefinitionExecResultMapper.selectPlanApiMaxResultByTestIdAndType(testId, type);
|
ApiDefinitionExecResultWithBLOBs result = extApiDefinitionExecResultMapper.selectPlanApiMaxResultByTestIdAndType(testId, type);
|
||||||
return buildAPIReportResult(result);
|
return buildAPIReportResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initOrderField() {
|
|
||||||
ServiceUtils.initOrderField(ApiDefinitionWithBLOBs.class, ApiDefinitionMapper.class, extApiDefinitionMapper::selectProjectIds, extApiDefinitionMapper::getIdsOrderByUpdateTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用例自定义排序
|
* 用例自定义排序
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,7 +4,6 @@ import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.ApiCaseExecutionInfoMapper;
|
import io.metersphere.base.mapper.ApiCaseExecutionInfoMapper;
|
||||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||||
import io.metersphere.base.mapper.ApiExecutionInfoMapper;
|
import io.metersphere.base.mapper.ApiExecutionInfoMapper;
|
||||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
|
||||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
|
import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||||
|
@ -36,8 +35,6 @@ public class ApiExecutionInfoService {
|
||||||
private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
|
private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionMapper apiDefinitionMapper;
|
private ApiDefinitionMapper apiDefinitionMapper;
|
||||||
@Resource
|
|
||||||
private ApiTestCaseMapper apiTestCaseMapper;
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
public void insertExecutionInfo(ApiDefinitionExecResult result) {
|
public void insertExecutionInfo(ApiDefinitionExecResult result) {
|
||||||
|
|
|
@ -264,7 +264,7 @@ public class ApiScenarioReportService {
|
||||||
report.setProjectId(projectId);
|
report.setProjectId(projectId);
|
||||||
report.setScenarioName(scenarioNames);
|
report.setScenarioName(scenarioNames);
|
||||||
report.setScenarioId(scenarioIds);
|
report.setScenarioId(scenarioIds);
|
||||||
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) {
|
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals(CommonConstants.CASE)) {
|
||||||
report.setTriggerMode(TriggerMode.MANUAL.name());
|
report.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
}
|
}
|
||||||
apiScenarioReportMapper.insert(report);
|
apiScenarioReportMapper.insert(report);
|
||||||
|
@ -280,14 +280,14 @@ public class ApiScenarioReportService {
|
||||||
if (StringUtils.equals(reportType, RunModeConstants.SET_REPORT.toString())) {
|
if (StringUtils.equals(reportType, RunModeConstants.SET_REPORT.toString())) {
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
if (StringUtils.equals(runMode, "CASE")) {
|
if (StringUtils.equals(runMode, CommonConstants.CASE)) {
|
||||||
report.setTriggerMode(TriggerMode.MANUAL.name());
|
report.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
}
|
}
|
||||||
report.setStatus(status);
|
report.setStatus(status);
|
||||||
report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
||||||
report.setEndTime(System.currentTimeMillis());
|
report.setEndTime(System.currentTimeMillis());
|
||||||
report.setUpdateTime(System.currentTimeMillis());
|
report.setUpdateTime(System.currentTimeMillis());
|
||||||
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) {
|
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals(CommonConstants.CASE)) {
|
||||||
report.setTriggerMode(TriggerMode.MANUAL.name());
|
report.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
}
|
}
|
||||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||||
|
@ -309,7 +309,7 @@ public class ApiScenarioReportService {
|
||||||
report.setStatus(test.getStatus());
|
report.setStatus(test.getStatus());
|
||||||
report.setUserId(test.getUserId());
|
report.setUserId(test.getUserId());
|
||||||
report.setExecuteType(test.getExecuteType());
|
report.setExecuteType(test.getExecuteType());
|
||||||
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) {
|
if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals(CommonConstants.CASE)) {
|
||||||
report.setTriggerMode(TriggerMode.MANUAL.name());
|
report.setTriggerMode(TriggerMode.MANUAL.name());
|
||||||
}
|
}
|
||||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||||
|
|
|
@ -1345,7 +1345,7 @@ public class ApiScenarioService {
|
||||||
String context = SessionUtils.getUserId().concat(Translator.get("update_scenario")).concat(":").concat(apiScenario.getName());
|
String context = SessionUtils.getUserId().concat(Translator.get("update_scenario")).concat(":").concat(apiScenario.getName());
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
getParamMap(paramMap, apiScenario.getProjectId(), SessionUtils.getUserId(), apiScenario.getId(), apiScenario.getName(), apiScenario.getCreateUser());
|
getParamMap(paramMap, apiScenario.getProjectId(), SessionUtils.getUserId(), apiScenario.getId(), apiScenario.getName(), apiScenario.getCreateUser());
|
||||||
paramMap.put("userId", apiScenario.getUserId());
|
paramMap.put(CommonConstants.USER_ID, apiScenario.getUserId());
|
||||||
NoticeModel noticeModel = NoticeModel.builder().operator(SessionUtils.getUserId()).context(context).testId(apiScenario.getId()).subject(Translator.get("scenario_update_notice")).paramMap(paramMap).excludeSelf(true).event(NoticeConstants.Event.UPDATE).build();
|
NoticeModel noticeModel = NoticeModel.builder().operator(SessionUtils.getUserId()).context(context).testId(apiScenario.getId()).subject(Translator.get("scenario_update_notice")).paramMap(paramMap).excludeSelf(true).event(NoticeConstants.Event.UPDATE).build();
|
||||||
noticeSendService.send(NoticeConstants.TaskType.API_AUTOMATION_TASK, noticeModel);
|
noticeSendService.send(NoticeConstants.TaskType.API_AUTOMATION_TASK, noticeModel);
|
||||||
}
|
}
|
||||||
|
@ -1354,7 +1354,7 @@ public class ApiScenarioService {
|
||||||
String context = SessionUtils.getUserId().concat(Translator.get("create_scenario")).concat(":").concat(apiScenario.getName());
|
String context = SessionUtils.getUserId().concat(Translator.get("create_scenario")).concat(":").concat(apiScenario.getName());
|
||||||
Map<String, Object> paramMap = new HashMap<>();
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
getParamMap(paramMap, apiScenario.getProjectId(), SessionUtils.getUserId(), apiScenario.getId(), apiScenario.getName(), apiScenario.getCreateUser());
|
getParamMap(paramMap, apiScenario.getProjectId(), SessionUtils.getUserId(), apiScenario.getId(), apiScenario.getName(), apiScenario.getCreateUser());
|
||||||
paramMap.put("userId", apiScenario.getUserId());
|
paramMap.put(CommonConstants.USER_ID, apiScenario.getUserId());
|
||||||
NoticeModel noticeModel = NoticeModel.builder().operator(SessionUtils.getUserId()).context(context).testId(apiScenario.getId()).subject(Translator.get("scenario_create_notice")).paramMap(paramMap).excludeSelf(true).event(NoticeConstants.Event.CREATE).build();
|
NoticeModel noticeModel = NoticeModel.builder().operator(SessionUtils.getUserId()).context(context).testId(apiScenario.getId()).subject(Translator.get("scenario_create_notice")).paramMap(paramMap).excludeSelf(true).event(NoticeConstants.Event.CREATE).build();
|
||||||
noticeSendService.send(NoticeConstants.TaskType.API_AUTOMATION_TASK, noticeModel);
|
noticeSendService.send(NoticeConstants.TaskType.API_AUTOMATION_TASK, noticeModel);
|
||||||
}
|
}
|
||||||
|
@ -1563,7 +1563,7 @@ public class ApiScenarioService {
|
||||||
// 检测引用对象是否存在,若果不存在则改成复制对象
|
// 检测引用对象是否存在,若果不存在则改成复制对象
|
||||||
String refType = object.optString("refType");
|
String refType = object.optString("refType");
|
||||||
if (StringUtils.isNotEmpty(refType)) {
|
if (StringUtils.isNotEmpty(refType)) {
|
||||||
if (refType.equals("CASE")) {
|
if (refType.equals(CommonConstants.CASE)) {
|
||||||
if (object.optJSONArray(ElementConstants.HASH_TREE) == null || object.optJSONArray(ElementConstants.HASH_TREE).length() == 0) {
|
if (object.optJSONArray(ElementConstants.HASH_TREE) == null || object.optJSONArray(ElementConstants.HASH_TREE).length() == 0) {
|
||||||
ApiTestCaseInfo model = extApiTestCaseMapper.selectApiCaseInfoByPrimaryKey(object.optString("id"));
|
ApiTestCaseInfo model = extApiTestCaseMapper.selectApiCaseInfoByPrimaryKey(object.optString("id"));
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
|
@ -2127,7 +2127,7 @@ public class ApiScenarioService {
|
||||||
// 检测引用对象是否存在,若果不存在则改成复制对象
|
// 检测引用对象是否存在,若果不存在则改成复制对象
|
||||||
String refType = object.optString("refType");
|
String refType = object.optString("refType");
|
||||||
if (StringUtils.isNotEmpty(refType)) {
|
if (StringUtils.isNotEmpty(refType)) {
|
||||||
if (refType.equals("CASE")) {
|
if (refType.equals(CommonConstants.CASE)) {
|
||||||
ApiScenarioImportUtil.checkCase(object, versionId, projectId, apiScenarioParamDto);
|
ApiScenarioImportUtil.checkCase(object, versionId, projectId, apiScenarioParamDto);
|
||||||
} else {
|
} else {
|
||||||
checkAutomation(object);
|
checkAutomation(object);
|
||||||
|
|
|
@ -93,6 +93,15 @@ public class JmeterRunRequestDTO {
|
||||||
public JmeterRunRequestDTO() {
|
public JmeterRunRequestDTO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JmeterRunRequestDTO(String testId, String reportId, String runMode) {
|
||||||
|
this.testId = testId;
|
||||||
|
this.reportId = reportId;
|
||||||
|
this.runMode = runMode;
|
||||||
|
this.reportType = RunModeConstants.INDEPENDENCE.name();
|
||||||
|
this.pool = new BooleanPool();
|
||||||
|
this.extendedParameters = new LinkedHashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
public JmeterRunRequestDTO(String testId, String reportId, String runMode, HashTree hashTree) {
|
public JmeterRunRequestDTO(String testId, String reportId, String runMode, HashTree hashTree) {
|
||||||
this.testId = testId;
|
this.testId = testId;
|
||||||
this.reportId = reportId;
|
this.reportId = reportId;
|
||||||
|
|
Loading…
Reference in New Issue