fix(接口测试): 修复历史数据模块匹配错误问题
This commit is contained in:
parent
4939816ac3
commit
7d05f30c91
|
@ -10,7 +10,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.metersphere.api.dto.definition.parse.JMeterScriptUtil;
|
import io.metersphere.api.dto.definition.parse.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.definition.request.assertions.MsAssertions;
|
|
||||||
import io.metersphere.api.dto.definition.request.auth.MsAuthManager;
|
import io.metersphere.api.dto.definition.request.auth.MsAuthManager;
|
||||||
import io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager;
|
import io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager;
|
||||||
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
|
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
|
||||||
|
@ -38,7 +37,6 @@ 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.FileUtils;
|
import io.metersphere.commons.utils.FileUtils;
|
||||||
import io.metersphere.commons.utils.HashTreeUtil;
|
|
||||||
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.jmeter.utils.ScriptEngineUtils;
|
import io.metersphere.jmeter.utils.ScriptEngineUtils;
|
||||||
|
@ -282,20 +280,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
this.setScript(httpConfig, httpSamplerTree, config, false);
|
this.setScript(httpConfig, httpSamplerTree, config, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashTreeUtil hashTreeUtil = new HashTreeUtil();
|
|
||||||
//增加误报、断言
|
|
||||||
if (httpConfig != null) {
|
|
||||||
if (CollectionUtils.isNotEmpty(httpConfig.getErrorReportAssertions())) {
|
|
||||||
for (MsAssertions assertion : httpConfig.getErrorReportAssertions()) {
|
|
||||||
assertion.toHashTree(httpSamplerTree, assertion.getHashTree(), config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(httpConfig.getAssertions())) {
|
|
||||||
for (MsAssertions assertion : httpConfig.getAssertions()) {
|
|
||||||
assertion.toHashTree(httpSamplerTree, assertion.getHashTree(), config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||||
for (MsTestElement el : hashTree) {
|
for (MsTestElement el : hashTree) {
|
||||||
if (el.getEnvironmentId() == null) {
|
if (el.getEnvironmentId() == null) {
|
||||||
|
@ -305,10 +289,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
el.setEnvironmentId(this.getEnvironmentId());
|
el.setEnvironmentId(this.getEnvironmentId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (el instanceof MsAssertions) {
|
|
||||||
//断言设置需要和全局断言、误报进行去重
|
|
||||||
el = hashTreeUtil.duplicateRegexInAssertions(httpConfig.getAssertions(), (MsAssertions) el);
|
|
||||||
}
|
|
||||||
el.toHashTree(httpSamplerTree, el.getHashTree(), config);
|
el.toHashTree(httpSamplerTree, el.getHashTree(), config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,10 +386,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
httpConfig.setPreProcessor(environmentConfig.getPreProcessor());
|
httpConfig.setPreProcessor(environmentConfig.getPreProcessor());
|
||||||
httpConfig.setPostProcessor(environmentConfig.getPostProcessor());
|
httpConfig.setPostProcessor(environmentConfig.getPostProcessor());
|
||||||
httpConfig.setGlobalScriptConfig(environmentConfig.getGlobalScriptConfig());
|
httpConfig.setGlobalScriptConfig(environmentConfig.getGlobalScriptConfig());
|
||||||
httpConfig.setAssertions(environmentConfig.getAssertions());
|
|
||||||
if (environmentConfig.isUseErrorCode()) {
|
|
||||||
httpConfig.setErrorReportAssertions(HashTreeUtil.getErrorReportByProjectId(this.getProjectId()));
|
|
||||||
}
|
|
||||||
return httpConfig;
|
return httpConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,13 +405,12 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
this.useEnvironment = config.getConfig().get(this.getProjectId()).getApiEnvironmentid();
|
this.useEnvironment = config.getConfig().get(this.getProjectId()).getApiEnvironmentid();
|
||||||
}
|
}
|
||||||
String url = httpConfig.getProtocol() + "://" + httpConfig.getSocket();
|
String url = httpConfig.getProtocol() + "://" + httpConfig.getSocket();
|
||||||
// 补充如果是完整URL 则用自身URL
|
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(this.getUrl()) && ElementUtil.isURL(this.getUrl())) {
|
|
||||||
url = this.getUrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isUrl()) {
|
if (isUrl()) {
|
||||||
|
// 补充如果是完整URL 则用自身URL
|
||||||
|
if (StringUtils.isNotEmpty(this.getUrl()) && ElementUtil.isURL(this.getUrl())) {
|
||||||
|
url = this.getUrl();
|
||||||
|
}
|
||||||
if (this.isCustomizeReq()) {
|
if (this.isCustomizeReq()) {
|
||||||
url = this.getUrl();
|
url = this.getUrl();
|
||||||
sampler.setProperty("HTTPSampler.path", url);
|
sampler.setProperty("HTTPSampler.path", url);
|
||||||
|
@ -657,9 +632,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(this.getUrl()) && ElementUtil.isURL(this.getUrl())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,19 +808,22 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
apiDefinition = apiDefinitionService.get(this.getId());
|
apiDefinition = apiDefinitionService.get(this.getId());
|
||||||
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseService.get(this.getId());
|
apiDefinition = apiDefinition == null ? apiDefinitionService.get(this.getName()) : apiDefinition;
|
||||||
if (apiTestCaseWithBLOBs == null) {
|
if (apiDefinition == null) {
|
||||||
apiTestCaseWithBLOBs = apiTestCaseService.get(this.getName());
|
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseService.get(this.getId());
|
||||||
}
|
if (apiTestCaseWithBLOBs == null) {
|
||||||
if (apiTestCaseWithBLOBs != null) {
|
apiTestCaseWithBLOBs = apiTestCaseService.get(this.getName());
|
||||||
apiDefinition = apiDefinitionService.get(apiTestCaseWithBLOBs.getApiDefinitionId());
|
}
|
||||||
} else {
|
if (apiTestCaseWithBLOBs != null) {
|
||||||
TestPlanApiCaseService testPlanApiCaseService = CommonBeanFactory.getBean(TestPlanApiCaseService.class);
|
apiDefinition = apiDefinitionService.get(apiTestCaseWithBLOBs.getApiDefinitionId());
|
||||||
TestPlanApiCase testPlanApiCase = testPlanApiCaseService.getById(this.getId());
|
} else {
|
||||||
if (testPlanApiCase != null) {
|
TestPlanApiCaseService testPlanApiCaseService = CommonBeanFactory.getBean(TestPlanApiCaseService.class);
|
||||||
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(testPlanApiCase.getApiCaseId());
|
TestPlanApiCase testPlanApiCase = testPlanApiCaseService.getById(this.getId());
|
||||||
if (caseWithBLOBs != null) {
|
if (testPlanApiCase != null) {
|
||||||
apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId());
|
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(testPlanApiCase.getApiCaseId());
|
||||||
|
if (caseWithBLOBs != null) {
|
||||||
|
apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue