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.KeyValue;
|
||||
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.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.base.domain.TestPlanApiCase;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ConditionType;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
|
@ -19,6 +17,9 @@ import io.metersphere.environment.ssl.MsKeyStore;
|
|||
import io.metersphere.jmeter.utils.ScriptEngineUtils;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
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 org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -130,7 +131,7 @@ public class ParameterConfig extends MsParameter {
|
|||
ApiDefinition apiDefinition = null;
|
||||
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.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());
|
||||
if (caseWithBLOBs != null) {
|
||||
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.KeyValue;
|
||||
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.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.JSONUtil;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
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.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -183,7 +184,7 @@ public class MsJDBCPostProcessor extends MsTestElement {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
MsJDBCPostProcessor proxy = null;
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||
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.KeyValue;
|
||||
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.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.constants.RequestTypeConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.JSONUtil;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
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.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -47,7 +48,6 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
public class MsJDBCPreProcessor extends MsTestElement {
|
||||
// type 必须放最前面,以便能够转换正确的类
|
||||
private String type = ElementConstants.JDBC_PRE;
|
||||
|
@ -172,7 +172,7 @@ public class MsJDBCPreProcessor extends MsTestElement {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
MsJDBCPreProcessor proxy = null;
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||
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.GlobalScriptFilterRequest;
|
||||
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.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.JSONUtil;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
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.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -43,42 +44,24 @@ import java.util.stream.Collectors;
|
|||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
public class MsDubboSampler extends MsTestElement {
|
||||
private String clazzName = MsDubboSampler.class.getCanonicalName();
|
||||
|
||||
/**
|
||||
* type 必须放最前面,以便能够转换正确的类
|
||||
*/
|
||||
private String type = ElementConstants.DUBBO_SAMPLER;
|
||||
|
||||
|
||||
private final String protocol = "dubbo://";
|
||||
@JsonProperty(value = "interface")
|
||||
|
||||
private String _interface;
|
||||
|
||||
private String method;
|
||||
|
||||
|
||||
private MsConfigCenter configCenter;
|
||||
|
||||
private MsRegistryCenter registryCenter;
|
||||
|
||||
private MsConsumerAndService consumerAndService;
|
||||
|
||||
|
||||
private List<KeyValue> args;
|
||||
|
||||
private List<KeyValue> attachmentArgs;
|
||||
|
||||
|
||||
private String useEnvironment;
|
||||
|
||||
|
||||
private boolean customizeReq;
|
||||
|
||||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
|
@ -134,7 +117,7 @@ public class MsDubboSampler extends MsTestElement {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
MsDubboSampler proxy = null;
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||
if (bloBs != null) {
|
||||
|
@ -155,7 +138,7 @@ public class MsDubboSampler extends MsTestElement {
|
|||
}
|
||||
}
|
||||
if (proxy != null) {
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||
} else {
|
||||
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.parse.api.JMeterScriptUtil;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
|
@ -82,6 +83,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
private Boolean isRefEnvironment;
|
||||
private String alias;
|
||||
private boolean customizeReq;
|
||||
private final static String DEF_TIME_OUT = "60000";
|
||||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
|
@ -134,8 +136,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
config.compatible(this);
|
||||
this.initConnectAndResponseTimeout(config);
|
||||
sampler.setConnectTimeout(this.getConnectTimeout() == null ? "60000" : this.getConnectTimeout());
|
||||
sampler.setResponseTimeout(this.getResponseTimeout() == null ? "60000" : this.getResponseTimeout());
|
||||
sampler.setConnectTimeout(this.getConnectTimeout() == null ? DEF_TIME_OUT : this.getConnectTimeout());
|
||||
sampler.setResponseTimeout(this.getResponseTimeout() == null ? DEF_TIME_OUT : this.getResponseTimeout());
|
||||
HttpConfig httpConfig = getHttpConfig(config);
|
||||
setSamplerPath(config, httpConfig, sampler);
|
||||
// 请求体处理
|
||||
|
@ -246,7 +248,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
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());
|
||||
if (bloBs != null) {
|
||||
this.setProjectId(bloBs.getProjectId());
|
||||
|
@ -258,7 +260,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
}
|
||||
if (proxy != null) {
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||
} else {
|
||||
this.setHashTree(proxy.getHashTree());
|
||||
|
@ -285,12 +287,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
CommonConfig commonConfig = config.getConfig().get(this.getProjectId()).getCommonConfig();
|
||||
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) {
|
||||
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) {
|
||||
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.databind.DeserializationFeature;
|
||||
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.ParameterConfig;
|
||||
import io.metersphere.api.dto.scenario.DatabaseConfig;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
||||
import io.metersphere.service.definition.ApiDefinitionService;
|
||||
import io.metersphere.service.definition.ApiTestCaseService;
|
||||
import io.metersphere.api.parse.api.JMeterScriptUtil;
|
||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
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.constants.RunModeConstants;
|
||||
import io.metersphere.environment.service.BaseEnvironmentService;
|
||||
import io.metersphere.plugin.core.MsParameter;
|
||||
import io.metersphere.plugin.core.MsTestElement;
|
||||
import io.metersphere.commons.utils.HashTreeUtil;
|
||||
import io.metersphere.commons.utils.JSONUtil;
|
||||
import io.metersphere.service.definition.ApiDefinitionService;
|
||||
import io.metersphere.service.definition.ApiTestCaseService;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -198,7 +199,7 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
MsJDBCSampler proxy = null;
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||
if (bloBs != null) {
|
||||
|
@ -219,7 +220,7 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
}
|
||||
}
|
||||
if (proxy != null) {
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||
} else {
|
||||
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.base.domain.ApiDefinitionWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
|
@ -183,7 +184,7 @@ public class MsTCPSampler extends MsTestElement {
|
|||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
MsTCPSampler proxy = null;
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||
ApiTestCaseWithBLOBs bloBs = apiTestCaseService.get(this.getId());
|
||||
if (bloBs != null) {
|
||||
|
@ -204,7 +205,7 @@ public class MsTCPSampler extends MsTestElement {
|
|||
}
|
||||
}
|
||||
if (proxy != null) {
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(this.getRefType(), CommonConstants.CASE)) {
|
||||
ElementUtil.mergeHashTree(this, proxy.getHashTree());
|
||||
} else {
|
||||
this.setHashTree(proxy.getHashTree());
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package io.metersphere.api.exec.api;
|
||||
|
||||
import io.metersphere.api.exec.queue.DBTestQueue;
|
||||
import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
||||
import io.metersphere.api.jmeter.JMeterService;
|
||||
import io.metersphere.api.jmeter.utils.SmoothWeighted;
|
||||
import io.metersphere.base.domain.ApiDefinitionExecResultWithBLOBs;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.GenerateHashTreeUtil;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.dto.JmeterRunRequestDTO;
|
||||
|
@ -45,7 +46,7 @@ public class ApiCaseParallelExecuteService {
|
|||
}
|
||||
ApiDefinitionExecResultWithBLOBs result = executeQueue.get(testId);
|
||||
String reportId = result.getId();
|
||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testId, reportId, runMode, null);
|
||||
JmeterRunRequestDTO runRequest = new JmeterRunRequestDTO(testId, reportId, runMode);
|
||||
runRequest.setPool(pool);
|
||||
runRequest.setTestPlanReportId(executionQueue.getReportId());
|
||||
runRequest.setPoolId(config.getResourcePoolId());
|
||||
|
@ -57,7 +58,7 @@ public class ApiCaseParallelExecuteService {
|
|||
runRequest.setRetryEnable(config.isRetryEnable());
|
||||
|
||||
Map<String, Object> extendedParameters = new HashMap<>();
|
||||
extendedParameters.put("userId", result.getUserId());
|
||||
extendedParameters.put(CommonConstants.USER_ID, result.getUserId());
|
||||
runRequest.setExtendedParameters(extendedParameters);
|
||||
if (MapUtils.isNotEmpty(executionQueue.getDetailMap())) {
|
||||
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.plan.TestPlanApiCaseMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.PropertyConstant;
|
||||
import io.metersphere.commons.enums.ApiReportStatus;
|
||||
|
@ -99,7 +100,7 @@ public class ApiCaseSerialService {
|
|||
ApiDefinitionExecResultWithBLOBs execResult = apiDefinitionExecResultMapper.selectByPrimaryKey(queue.getReportId());
|
||||
if (execResult != null) {
|
||||
runRequest.setExtendedParameters(new HashMap<String, Object>() {{
|
||||
this.put("userId", execResult.getUserId());
|
||||
this.put(CommonConstants.USER_ID, execResult.getUserId());
|
||||
}});
|
||||
execResult.setStartTime(System.currentTimeMillis());
|
||||
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.plan.TestPlanApiCaseMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.ExtendedParameter;
|
||||
import io.metersphere.commons.enums.ApiReportStatus;
|
||||
|
@ -254,7 +255,7 @@ public class ApiExecuteService {
|
|||
runRequest.setRunMode(runMode);
|
||||
runRequest.setExtendedParameters(new HashMap<String, Object>() {{
|
||||
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());
|
||||
}});
|
||||
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.plan.TestPlanApiScenarioMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||
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.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -53,7 +53,6 @@ public class ApiScenarioEnvService {
|
|||
private ApiTestEnvironmentMapper apiTestEnvironmentMapper;
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Lazy
|
||||
@Resource
|
||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||
@Resource
|
||||
|
@ -99,7 +98,7 @@ public class ApiScenarioEnvService {
|
|||
if (StringUtils.equals(testElement.getType(), ElementConstants.HTTP_SAMPLER)) {
|
||||
MsHTTPSamplerProxy http = (MsHTTPSamplerProxy) testElement;
|
||||
// 引用用例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())) {
|
||||
|
@ -108,7 +107,7 @@ public class ApiScenarioEnvService {
|
|||
}
|
||||
} else if (StringUtils.equals(testElement.getType(), ElementConstants.JDBC_SAMPLER) || StringUtils.equals(testElement.getType(), ElementConstants.TCP_SAMPLER)) {
|
||||
if (StringUtils.isEmpty(testElement.getProjectId())) {
|
||||
if (StringUtils.equals(testElement.getRefType(), "CASE")) {
|
||||
if (StringUtils.equals(testElement.getRefType(), CommonConstants.CASE)) {
|
||||
ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(testElement.getId());
|
||||
if (testCase != null) {
|
||||
env.getProjectIds().add(testCase.getProjectId());
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ApiScenarioParallelService {
|
|||
|
||||
protected JmeterRunRequestDTO getJmeterRunRequestDTO(RunScenarioRequest request, String serialReportId, DBTestQueue executionQueue,
|
||||
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.setQueueId(executionQueue.getId());
|
||||
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.plan.TestPlanApiScenarioMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
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.HashTreeUtil;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
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.jorphan.collections.HashTree;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
@ -123,7 +124,7 @@ public class ApiScenarioSerialService {
|
|||
report.setCreateTime(System.currentTimeMillis());
|
||||
report.setUpdateTime(System.currentTimeMillis());
|
||||
runRequest.setExtendedParameters(new HashMap<>() {{
|
||||
this.put("userId", report.getCreateUser());
|
||||
this.put(CommonConstants.USER_ID, report.getCreateUser());
|
||||
}});
|
||||
apiScenarioReportMapper.updateByPrimaryKey(report);
|
||||
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.databind.ObjectMapper;
|
||||
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.TestResultService;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.dto.ResultDTO;
|
||||
import io.metersphere.utils.LoggerUtil;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -54,10 +55,10 @@ public class KafkaListenerTask implements Runnable {
|
|||
if (dto == null) {
|
||||
return;
|
||||
}
|
||||
if (dto.getArbitraryData() != null && dto.getArbitraryData().containsKey("TEST_END")
|
||||
&& (Boolean) dto.getArbitraryData().get("TEST_END")) {
|
||||
if (dto.getArbitraryData() != null && dto.getArbitraryData().containsKey(ExtendedParameter.TEST_END)
|
||||
&& (Boolean) dto.getArbitraryData().get(ExtendedParameter.TEST_END)) {
|
||||
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())) {
|
||||
|
|
|
@ -162,6 +162,4 @@ public class MsApiBackendListener extends AbstractBackendListenerClient implemen
|
|||
}
|
||||
return reportId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,5 +8,7 @@ public class CommonConstants {
|
|||
public static final String TRIGGER_MODE = "trigger_mode";
|
||||
|
||||
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 SAVE_RESULT = "SAVE_RESULT";
|
||||
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 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.setRetryNum(queue.getRetryNumber());
|
||||
runRequest.setReportType(executionQueue.getReportType());
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ApiJMeterFileService {
|
|||
|
||||
public byte[] downloadJmeterFiles(String runMode, String remoteTestId, String reportId, String reportType, String queueId) {
|
||||
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.setQueueId(queueId);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.metersphere.base.domain.Project;
|
|||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.ElementConstants;
|
||||
import io.metersphere.commons.constants.PropertyConstant;
|
||||
import io.metersphere.commons.utils.JSON;
|
||||
|
@ -45,7 +46,7 @@ public class MsHashTreeService {
|
|||
@Resource
|
||||
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 REF = "REF";
|
||||
public static final String COPY = "Copy";
|
||||
|
@ -77,8 +78,8 @@ public class MsHashTreeService {
|
|||
private static final String PRE = "PRE";
|
||||
private static final String POST = "POST";
|
||||
private static final String ASSERTIONS = ElementConstants.ASSERTIONS;
|
||||
public static final String CUSTOMNUM = "customNum";
|
||||
public static final String SHOWCUSTOMNUM = "showCustomNum";
|
||||
public static final String CUSTOM_NUM = "customNum";
|
||||
public static final String SHOW_CUSTOM_NUM = "showCustomNum";
|
||||
|
||||
public void setHashTree(JSONArray hashTree) {
|
||||
// 将引用转成复制
|
||||
|
@ -218,8 +219,8 @@ public class MsHashTreeService {
|
|||
}
|
||||
//获取场景的当前项目是否开启了自定义id
|
||||
ProjectConfig projectApplication = baseProjectApplicationService.getSpecificTypeValue(scenarioWithBLOBs.getProjectId(), "SCENARIO_CUSTOM_NUM");
|
||||
element.put(SHOWCUSTOMNUM, projectApplication.getScenarioCustomNum());
|
||||
element.put(CUSTOMNUM, scenarioWithBLOBs.getCustomNum());
|
||||
element.put(SHOW_CUSTOM_NUM, projectApplication.getScenarioCustomNum());
|
||||
element.put(CUSTOM_NUM, scenarioWithBLOBs.getCustomNum());
|
||||
this.setElement(element, scenarioWithBLOBs.getNum(), enable, scenarioWithBLOBs.getVersionName(), scenarioWithBLOBs.getVersionEnable());
|
||||
} else {
|
||||
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.plan.TestPlanApiCaseMapper;
|
||||
import io.metersphere.commons.constants.ApiRunMode;
|
||||
import io.metersphere.commons.constants.CommonConstants;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.TriggerMode;
|
||||
import io.metersphere.commons.enums.ApiReportStatus;
|
||||
|
@ -96,14 +97,14 @@ public class ApiDefinitionExecResultService {
|
|||
apiExecutionInfoService.insertExecutionInfo(result);
|
||||
User user = null;
|
||||
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() {{
|
||||
this.setId(dto.getExtendedParameters().get("userId").toString());
|
||||
this.setId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
||||
this.setName(dto.getExtendedParameters().get("userName").toString());
|
||||
}};
|
||||
result.setUserId(user.getId());
|
||||
} else if (dto.getExtendedParameters().containsKey("userId")) {
|
||||
result.setUserId(dto.getExtendedParameters().get("userId").toString());
|
||||
} else if (dto.getExtendedParameters().containsKey(CommonConstants.USER_ID)) {
|
||||
result.setUserId(dto.getExtendedParameters().get(CommonConstants.USER_ID).toString());
|
||||
}
|
||||
}
|
||||
//如果是测试计划用例,更新接口用例的上次执行结果
|
||||
|
@ -302,8 +303,8 @@ public class ApiDefinitionExecResultService {
|
|||
LoggerUtil.info("执行结果【 " + item.getName() + " 】入库存储");
|
||||
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);
|
||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("userId")) {
|
||||
reportResult.setUserId(String.valueOf(dto.getExtendedParameters().get("userId")));
|
||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey(CommonConstants.USER_ID)) {
|
||||
reportResult.setUserId(String.valueOf(dto.getExtendedParameters().get(CommonConstants.USER_ID)));
|
||||
}
|
||||
String triggerMode = StringUtils.EMPTY;
|
||||
if (reportResult != null) {
|
||||
|
@ -402,7 +403,7 @@ public class ApiDefinitionExecResultService {
|
|||
if (item.getStartTime() >= item.getEndTime()) {
|
||||
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());
|
||||
}
|
||||
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.StringUtils;
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.constants.CommonConstants;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
|
@ -142,8 +141,6 @@ public class ApiDefinitionService {
|
|||
private EsbApiParamsMapper esbApiParamsMapper;
|
||||
@Resource
|
||||
private ApiExecutionInfoService apiExecutionInfoService;
|
||||
@Resource
|
||||
private ApiCaseExecutionInfoService apiCaseExecutionInfoService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private ApiModuleService apiModuleService;
|
||||
|
@ -1608,11 +1605,6 @@ public class ApiDefinitionService {
|
|||
return buildAPIReportResult(result);
|
||||
}
|
||||
|
||||
public ApiReportResult getByResultId(String reportId) {
|
||||
ApiDefinitionExecResultWithBLOBs result = apiDefinitionExecResultMapper.selectByPrimaryKey(reportId);
|
||||
return buildAPIReportResult(result);
|
||||
}
|
||||
|
||||
public ApiReportResult getReportById(String testId) {
|
||||
ApiDefinitionExecResultWithBLOBs result = apiDefinitionExecResultMapper.selectByPrimaryKey(testId);
|
||||
return buildAPIReportResult(result);
|
||||
|
@ -1626,12 +1618,14 @@ public class ApiDefinitionService {
|
|||
reportResult.setStatus(result.getStatus());
|
||||
String contentStr = result.getContent();
|
||||
try {
|
||||
JSONObject content = JSONUtil.parseObject(result.getContent());
|
||||
if (StringUtils.isNotBlank(contentStr)) {
|
||||
JSONObject content = JSONUtil.parseObject(contentStr);
|
||||
if (StringUtils.isNotEmpty(result.getEnvConfig())) {
|
||||
content.put("envName", this.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig()));
|
||||
}
|
||||
contentStr = content.toString();
|
||||
reportResult.setContent(contentStr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error("解析content失败!", e);
|
||||
}
|
||||
|
@ -2495,7 +2489,7 @@ public class ApiDefinitionService {
|
|||
});
|
||||
} else if (StringUtils.isNotEmpty(request.getUserId())) {
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
@ -2521,26 +2515,11 @@ public class ApiDefinitionService {
|
|||
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) {
|
||||
ApiDefinitionExecResultWithBLOBs result = extApiDefinitionExecResultMapper.selectPlanApiMaxResultByTestIdAndType(testId, type);
|
||||
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.ApiDefinitionMapper;
|
||||
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.ExtApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
|
||||
|
@ -36,8 +35,6 @@ public class ApiExecutionInfoService {
|
|||
private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
|
||||
@Lazy
|
||||
public void insertExecutionInfo(ApiDefinitionExecResult result) {
|
||||
|
|
|
@ -264,7 +264,7 @@ public class ApiScenarioReportService {
|
|||
report.setProjectId(projectId);
|
||||
report.setScenarioName(scenarioNames);
|
||||
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());
|
||||
}
|
||||
apiScenarioReportMapper.insert(report);
|
||||
|
@ -280,14 +280,14 @@ public class ApiScenarioReportService {
|
|||
if (StringUtils.equals(reportType, RunModeConstants.SET_REPORT.toString())) {
|
||||
return report;
|
||||
}
|
||||
if (StringUtils.equals(runMode, "CASE")) {
|
||||
if (StringUtils.equals(runMode, CommonConstants.CASE)) {
|
||||
report.setTriggerMode(TriggerMode.MANUAL.name());
|
||||
}
|
||||
report.setStatus(status);
|
||||
report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis()));
|
||||
report.setEndTime(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());
|
||||
}
|
||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||
|
@ -309,7 +309,7 @@ public class ApiScenarioReportService {
|
|||
report.setStatus(test.getStatus());
|
||||
report.setUserId(test.getUserId());
|
||||
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());
|
||||
}
|
||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||
|
|
|
@ -1345,7 +1345,7 @@ public class ApiScenarioService {
|
|||
String context = SessionUtils.getUserId().concat(Translator.get("update_scenario")).concat(":").concat(apiScenario.getName());
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
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();
|
||||
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());
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
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();
|
||||
noticeSendService.send(NoticeConstants.TaskType.API_AUTOMATION_TASK, noticeModel);
|
||||
}
|
||||
|
@ -1563,7 +1563,7 @@ public class ApiScenarioService {
|
|||
// 检测引用对象是否存在,若果不存在则改成复制对象
|
||||
String refType = object.optString("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) {
|
||||
ApiTestCaseInfo model = extApiTestCaseMapper.selectApiCaseInfoByPrimaryKey(object.optString("id"));
|
||||
if (model != null) {
|
||||
|
@ -2127,7 +2127,7 @@ public class ApiScenarioService {
|
|||
// 检测引用对象是否存在,若果不存在则改成复制对象
|
||||
String refType = object.optString("refType");
|
||||
if (StringUtils.isNotEmpty(refType)) {
|
||||
if (refType.equals("CASE")) {
|
||||
if (refType.equals(CommonConstants.CASE)) {
|
||||
ApiScenarioImportUtil.checkCase(object, versionId, projectId, apiScenarioParamDto);
|
||||
} else {
|
||||
checkAutomation(object);
|
||||
|
|
|
@ -93,6 +93,15 @@ public class 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) {
|
||||
this.testId = testId;
|
||||
this.reportId = reportId;
|
||||
|
|
Loading…
Reference in New Issue