fix(接口自动化): 修复环境匹配取消,执行优化等 问题
This commit is contained in:
parent
006e382d5e
commit
e968eeac46
|
@ -18,12 +18,14 @@ import io.metersphere.api.service.ApiTestCaseService;
|
||||||
import io.metersphere.base.domain.ApiDefinition;
|
import io.metersphere.base.domain.ApiDefinition;
|
||||||
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.TestPlanApiCase;
|
||||||
import io.metersphere.commons.constants.ConditionType;
|
import io.metersphere.commons.constants.ConditionType;
|
||||||
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.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.commons.utils.ScriptEngineUtils;
|
import io.metersphere.commons.utils.ScriptEngineUtils;
|
||||||
|
import io.metersphere.track.service.TestPlanApiCaseService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -203,7 +205,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
if (config.isEffective(this.getProjectId())) {
|
if (config.isEffective(this.getProjectId())) {
|
||||||
HttpConfig httpConfig = getHttpConfig(config.getConfig().get(this.getProjectId()).getHttpConfig(), tree);
|
HttpConfig httpConfig = getHttpConfig(config.getConfig().get(this.getProjectId()).getHttpConfig(), tree);
|
||||||
if (httpConfig == null) {
|
if (httpConfig == null) {
|
||||||
MSException.throwException("未匹配到环境,请检查环境配置");
|
MSException.throwException(this.getName() + " 未匹配到环境,请检查环境配置");
|
||||||
}
|
}
|
||||||
String url = httpConfig.getProtocol() + "://" + httpConfig.getSocket();
|
String url = httpConfig.getProtocol() + "://" + httpConfig.getSocket();
|
||||||
// 补充如果是完整URL 则用自身URL
|
// 补充如果是完整URL 则用自身URL
|
||||||
|
@ -424,6 +426,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
tree.add(headerManager);
|
tree.add(headerManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照环境规则匹配环境
|
* 按照环境规则匹配环境
|
||||||
*
|
*
|
||||||
|
@ -444,12 +447,22 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
} else if (item.getType().equals(ConditionType.MODULE.name())) {
|
} else if (item.getType().equals(ConditionType.MODULE.name())) {
|
||||||
ApiDefinition apiDefinition;
|
ApiDefinition apiDefinition;
|
||||||
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
||||||
if (StringUtils.isNotEmpty(this.getReferenced()) && this.getReferenced().equals("REF") && StringUtils.isNotEmpty(this.getRefType()) && this.getRefType().equals("CASE")) {
|
|
||||||
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class);
|
||||||
|
if (StringUtils.isNotEmpty(this.getReferenced()) && this.getReferenced().equals("REF") && StringUtils.isNotEmpty(this.getRefType()) && this.getRefType().equals("CASE")) {
|
||||||
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(this.getId());
|
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(this.getId());
|
||||||
apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId());
|
apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId());
|
||||||
} else {
|
} else {
|
||||||
apiDefinition = apiDefinitionService.get(this.getId());
|
apiDefinition = apiDefinitionService.get(this.getId());
|
||||||
|
if (apiDefinition == null) {
|
||||||
|
TestPlanApiCaseService testPlanApiCaseService = CommonBeanFactory.getBean(TestPlanApiCaseService.class);
|
||||||
|
TestPlanApiCase testPlanApiCase = testPlanApiCaseService.getById(this.getId());
|
||||||
|
if (testPlanApiCase != null) {
|
||||||
|
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(testPlanApiCase.getApiCaseId());
|
||||||
|
if (caseWithBLOBs != null) {
|
||||||
|
apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (apiDefinition != null) {
|
if (apiDefinition != null) {
|
||||||
HttpConfig config = httpConfig.getModuleCondition(apiDefinition.getModuleId(), item);
|
HttpConfig config = httpConfig.getModuleCondition(apiDefinition.getModuleId(), item);
|
||||||
|
@ -470,7 +483,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (httpConfig != null && (StringUtils.isEmpty(httpConfig.getProtocol()) || StringUtils.isEmpty(httpConfig.getSocket()))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// 环境中请求头
|
// 环境中请求头
|
||||||
if (httpConfig != null) {
|
if (httpConfig != null) {
|
||||||
Arguments arguments = arguments(httpConfig.getHeaders());
|
Arguments arguments = arguments(httpConfig.getHeaders());
|
||||||
|
|
|
@ -189,20 +189,18 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
||||||
public int editNode(DragApiScenarioModuleRequest request) {
|
public int editNode(DragApiScenarioModuleRequest request) {
|
||||||
request.setUpdateTime(System.currentTimeMillis());
|
request.setUpdateTime(System.currentTimeMillis());
|
||||||
checkApiScenarioModuleExist(request);
|
checkApiScenarioModuleExist(request);
|
||||||
List<ApiScenarioDTO> apiScenarios = queryByModuleIds(request);
|
// List<ApiScenarioDTO> apiScenarios = queryByModuleIds(request);
|
||||||
|
// apiScenarios.forEach(apiScenario -> {
|
||||||
apiScenarios.forEach(apiScenario -> {
|
// StringBuilder path = new StringBuilder(apiScenario.getModulePath());
|
||||||
StringBuilder path = new StringBuilder(apiScenario.getModulePath());
|
// List<String> pathLists = Arrays.asList(path.toString().split("/"));
|
||||||
List<String> pathLists = Arrays.asList(path.toString().split("/"));
|
// pathLists.set(request.getLevel(), request.getName());
|
||||||
pathLists.set(request.getLevel(), request.getName());
|
// path.delete(0, path.length());
|
||||||
path.delete(0, path.length());
|
// for (int i = 1; i < pathLists.size(); i++) {
|
||||||
for (int i = 1; i < pathLists.size(); i++) {
|
// path.append("/").append(pathLists.get(i));
|
||||||
path.append("/").append(pathLists.get(i));
|
// }
|
||||||
}
|
// apiScenario.setModulePath(path.toString());
|
||||||
apiScenario.setModulePath(path.toString());
|
// });
|
||||||
});
|
// batchUpdateApiScenario(apiScenarios);
|
||||||
|
|
||||||
batchUpdateApiScenario(apiScenarios);
|
|
||||||
|
|
||||||
return apiScenarioModuleMapper.updateByPrimaryKeySelective(request);
|
return apiScenarioModuleMapper.updateByPrimaryKeySelective(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,15 +95,16 @@
|
||||||
if (valid) {
|
if (valid) {
|
||||||
let path = "/api/automation/create";
|
let path = "/api/automation/create";
|
||||||
this.setParameter();
|
this.setParameter();
|
||||||
this.$fileUpload(path, null, [], this.scenarioForm, () => {
|
|
||||||
this.visible = false;
|
|
||||||
if (saveAs) {
|
if (saveAs) {
|
||||||
this.scenarioForm.request = JSON.stringify(this.scenarioForm.request);
|
this.scenarioForm.request = JSON.stringify(this.scenarioForm.request);
|
||||||
this.$emit('saveAsEdit', this.scenarioForm);
|
this.$emit('saveAsEdit', this.scenarioForm);
|
||||||
|
this.visible = false;
|
||||||
} else {
|
} else {
|
||||||
|
this.$fileUpload(path, null, [], this.scenarioForm, () => {
|
||||||
|
this.visible = false;
|
||||||
this.$emit('refresh');
|
this.$emit('refresh');
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@
|
||||||
result() {
|
result() {
|
||||||
this.response = this.result;
|
this.response = this.result;
|
||||||
this.isActive = true;
|
this.isActive = true;
|
||||||
|
},
|
||||||
|
apiItem(){
|
||||||
|
this.getExecResult();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="request-form">
|
<div class="request-form">
|
||||||
<component :is="component" :isMax="isMax" :show-btn="showBtn"
|
<keep-alive>
|
||||||
|
<component v-bind:is="component" :isMax="isMax" :show-btn="showBtn"
|
||||||
:scenario="scenario" :controller="scenario" :timer="scenario" :assertions="scenario" :extract="scenario" :jsr223-processor="scenario" :request="scenario" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" :node="node"
|
:scenario="scenario" :controller="scenario" :timer="scenario" :assertions="scenario" :extract="scenario" :jsr223-processor="scenario" :request="scenario" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" :node="node"
|
||||||
:draggable="draggable" :title="title" :color="titleColor" :background-color="backgroundColor" @suggestClick="suggestClick(node)" :response="response"
|
:draggable="draggable" :title="title" :color="titleColor" :background-color="backgroundColor" @suggestClick="suggestClick(node)" :response="response"
|
||||||
@remove="remove" @copyRow="copyRow" @refReload="refReload" @openScenario="openScenario" :project-list="projectList" :env-map="envMap"/>
|
@remove="remove" @copyRow="copyRow" @refReload="refReload" @openScenario="openScenario" :project-list="projectList" :env-map="envMap"/>
|
||||||
|
</keep-alive>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
|
let flag = false;
|
||||||
if (this.projectId) {
|
if (this.projectId) {
|
||||||
this.$get('/api/environment/list/' + this.projectId, response => {
|
this.$get('/api/environment/list/' + this.projectId, response => {
|
||||||
this.environments = response.data;
|
this.environments = response.data;
|
||||||
|
@ -62,12 +63,16 @@
|
||||||
parseEnvironment(environment);
|
parseEnvironment(environment);
|
||||||
if (this.useEnvironment && this.useEnvironment === environment.id) {
|
if (this.useEnvironment && this.useEnvironment === environment.id) {
|
||||||
this.environmentId = this.useEnvironment;
|
this.environmentId = this.useEnvironment;
|
||||||
|
flag = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.environmentId = undefined;
|
this.environmentId = undefined;
|
||||||
}
|
}
|
||||||
|
if(this.useEnvironment && !flag){
|
||||||
|
this.$emit('setEnvironment', {});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
openEnvironmentConfig() {
|
openEnvironmentConfig() {
|
||||||
if (!this.projectId) {
|
if (!this.projectId) {
|
||||||
|
|
|
@ -3,7 +3,13 @@
|
||||||
<el-row type="flex">
|
<el-row type="flex">
|
||||||
<el-col>
|
<el-col>
|
||||||
<div style="font-size: 14px;color: #AAAAAA;float: left">{{$t('api_report.response_code')}} :</div>
|
<div style="font-size: 14px;color: #AAAAAA;float: left">{{$t('api_report.response_code')}} :</div>
|
||||||
<div style="font-size: 14px;color:#61C550;margin-top:2px;margin-left:10px;float: left">{{response.responseResult && response.responseResult.responseCode ? response.responseResult.responseCode :'0'}}</div>
|
<el-tooltip
|
||||||
|
:content="response.responseResult.responseCode"
|
||||||
|
placement="top">
|
||||||
|
<div class="node-title">
|
||||||
|
{{response.responseResult && response.responseResult.responseCode ? response.responseResult.responseCode :'0'}}
|
||||||
|
</div>
|
||||||
|
</el-tooltip>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col>
|
<el-col>
|
||||||
<div style="font-size: 14px;color: #AAAAAA;float: left">{{$t('api_report.response_time')}} :</div>
|
<div style="font-size: 14px;color: #AAAAAA;float: left">{{$t('api_report.response_time')}} :</div>
|
||||||
|
@ -37,4 +43,18 @@
|
||||||
.metric-container {
|
.metric-container {
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.node-title {
|
||||||
|
width: 150px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
padding: 0px 5px;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #61C550;
|
||||||
|
margin-top: 2px;
|
||||||
|
margin-left: 10px;
|
||||||
|
float: left
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue