parent
babfc6cfd3
commit
29ecd9fd11
|
@ -108,7 +108,7 @@ public abstract class MsTestElement {
|
|||
@JSONField(ordinal = 13)
|
||||
private boolean isMockEnvironment;
|
||||
@JSONField(ordinal = 14)
|
||||
private String useEnvironment;
|
||||
private String environmentId;
|
||||
private MsTestElement parent;
|
||||
|
||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||
|
|
|
@ -36,17 +36,17 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
//替换Metersphere环境变量
|
||||
if(StringUtils.isEmpty(this.getUseEnvironment())){
|
||||
if(StringUtils.isEmpty(this.getEnvironmentId())){
|
||||
if(config.getConfig() != null){
|
||||
if(config.getProjectId() != null){
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid();
|
||||
this.setUseEnvironment(evnId);
|
||||
this.setEnvironmentId(evnId);
|
||||
}else {
|
||||
Collection<EnvironmentConfig> evnConfigList = config.getConfig().values();
|
||||
if(evnConfigList!=null && !evnConfigList.isEmpty()){
|
||||
for (EnvironmentConfig configItem : evnConfigList) {
|
||||
String evnId = configItem.getApiEnvironmentid();
|
||||
this.setUseEnvironment(evnId);
|
||||
this.setEnvironmentId(evnId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
|
||||
}
|
||||
}
|
||||
script = StringUtils.replace(script, RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getUseEnvironment()+".\"");
|
||||
script = StringUtils.replace(script, RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getEnvironmentId()+".\"");
|
||||
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
|
|
|
@ -32,17 +32,17 @@ public class MsJSR223PostProcessor extends MsTestElement {
|
|||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
if(StringUtils.isEmpty(this.getUseEnvironment())){
|
||||
if(StringUtils.isEmpty(this.getEnvironmentId())){
|
||||
if(config.getConfig() != null){
|
||||
if(config.getProjectId() != null){
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid();
|
||||
this.setUseEnvironment(evnId);
|
||||
this.setEnvironmentId(evnId);
|
||||
}else {
|
||||
Collection<EnvironmentConfig> evnConfigList = config.getConfig().values();
|
||||
if(evnConfigList!=null && !evnConfigList.isEmpty()){
|
||||
for (EnvironmentConfig configItem : evnConfigList) {
|
||||
String evnId = configItem.getApiEnvironmentid();
|
||||
this.setUseEnvironment(evnId);
|
||||
this.setEnvironmentId(evnId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class MsJSR223PostProcessor extends MsTestElement {
|
|||
}
|
||||
}
|
||||
//替换Metersphere环境变量
|
||||
script = StringUtils.replace(script,RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getUseEnvironment()+".\"");
|
||||
script = StringUtils.replace(script,RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getEnvironmentId()+".\"");
|
||||
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
|
|
|
@ -32,17 +32,17 @@ public class MsJSR223PreProcessor extends MsTestElement {
|
|||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
if(StringUtils.isEmpty(this.getUseEnvironment())){
|
||||
if(StringUtils.isEmpty(this.getEnvironmentId())){
|
||||
if(config.getConfig() != null){
|
||||
if(config.getProjectId() != null){
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid();
|
||||
this.setUseEnvironment(evnId);
|
||||
this.setEnvironmentId(evnId);
|
||||
}else {
|
||||
Collection<EnvironmentConfig> evnConfigList = config.getConfig().values();
|
||||
if(evnConfigList!=null && !evnConfigList.isEmpty()){
|
||||
for (EnvironmentConfig configItem : evnConfigList) {
|
||||
String evnId = configItem.getApiEnvironmentid();
|
||||
this.setUseEnvironment(evnId);
|
||||
this.setEnvironmentId(evnId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class MsJSR223PreProcessor extends MsTestElement {
|
|||
}
|
||||
}
|
||||
//替换Metersphere环境变量
|
||||
script = StringUtils.replace(script,RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getUseEnvironment()+".\"");
|
||||
script = StringUtils.replace(script,RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getEnvironmentId()+".\"");
|
||||
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
|
|
|
@ -161,6 +161,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
if(StringUtils.isEmpty(this.getEnvironmentId())){
|
||||
this.setEnvironmentId(this.useEnvironment);
|
||||
}
|
||||
// 非导出操作,且不是启用状态则跳过执行
|
||||
if (!config.isOperating() && !this.isEnable()) {
|
||||
return;
|
||||
|
@ -252,7 +255,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
for (MsTestElement el : hashTree) {
|
||||
el.setUseEnvironment(useEnvironment);
|
||||
el.setEnvironmentId(useEnvironment);
|
||||
el.toHashTree(httpSamplerTree, el.getHashTree(), config);
|
||||
}
|
||||
}
|
||||
|
@ -266,8 +269,8 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
private HttpConfig getHttpConfig(ParameterConfig config) {
|
||||
if (config.isEffective(this.getProjectId())) {
|
||||
String useEvnId = config.getConfig().get(this.getProjectId()).getApiEnvironmentid();
|
||||
if(StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId,this.getUseEnvironment())){
|
||||
this.setUseEnvironment(useEvnId);
|
||||
if(StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId,this.getEnvironmentId())){
|
||||
this.setEnvironmentId(useEvnId);
|
||||
}
|
||||
return getHttpConfig(config.getConfig().get(this.getProjectId()).getHttpConfig());
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ import {saveScenario} from "@/business/components/api/automation/api-automation"
|
|||
this.$emit('runRefresh', {});
|
||||
this.$emit("changeDebugButton");
|
||||
});
|
||||
alert("123");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue