parent
ebce46296e
commit
9edba9ae52
|
@ -59,6 +59,8 @@ public class MsThreadGroup extends MsTestElement {
|
|||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
MsJSR223Processor preProcessor = null;
|
||||
MsJSR223Processor postProcessor = null;
|
||||
boolean isConnScenarioPre = false;
|
||||
boolean isConnScenarioPost = false;
|
||||
//获取projectConfig
|
||||
String projectId = this.checkProjectId(hashTree);
|
||||
this.checkEnviromentConfig(projectId,config,hashTree);
|
||||
|
@ -66,8 +68,12 @@ public class MsThreadGroup extends MsTestElement {
|
|||
if (config.isEffective(projectId)) {
|
||||
EnvironmentConfig environmentConfig = config.getConfig().get(projectId);
|
||||
if (environmentConfig != null) {
|
||||
preProcessor = environmentConfig.getPreProcessor();
|
||||
postProcessor = environmentConfig.getPostProcessor();
|
||||
preProcessor = environmentConfig.getPreStepProcessor();
|
||||
postProcessor = environmentConfig.getPostStepProcessor();
|
||||
if(environmentConfig.getGlobalScriptConfig() != null ){
|
||||
isConnScenarioPre = environmentConfig.getGlobalScriptConfig().isConnScenarioPreScript();
|
||||
isConnScenarioPost = environmentConfig.getGlobalScriptConfig().isConnScenarioPostScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +81,7 @@ public class MsThreadGroup extends MsTestElement {
|
|||
//检查全局前后置脚本
|
||||
if (preProcessor != null && StringUtils.isNotEmpty(preProcessor.getScript())) {
|
||||
preProcessor.setType("JSR223Processor");
|
||||
preProcessor.setName("PRE_PROCESSOR_ENV_"+preProcessor.isConnScenario());
|
||||
preProcessor.setName("PRE_PROCESSOR_ENV_"+isConnScenarioPre);
|
||||
preProcessor.setClazzName("io.metersphere.api.dto.definition.request.processors.MsJSR223Processor");
|
||||
preProcessor.toHashTree(groupTree, preProcessor.getHashTree(), config);
|
||||
}
|
||||
|
@ -85,7 +91,7 @@ public class MsThreadGroup extends MsTestElement {
|
|||
|
||||
if (postProcessor != null && StringUtils.isNotEmpty(postProcessor.getScript())) {
|
||||
postProcessor.setType("JSR223Processor");
|
||||
postProcessor.setName("POST_PROCESSOR_ENV_"+preProcessor.isConnScenario());
|
||||
postProcessor.setName("POST_PROCESSOR_ENV_"+isConnScenarioPost);
|
||||
postProcessor.setClazzName("io.metersphere.api.dto.definition.request.processors.MsJSR223Processor");
|
||||
postProcessor.toHashTree(groupTree, postProcessor.getHashTree(), config);
|
||||
}
|
||||
|
|
|
@ -36,9 +36,6 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
@JSONField(ordinal = 21)
|
||||
private String scriptLanguage;
|
||||
|
||||
@JSONField(ordinal = 22)
|
||||
private boolean connScenario = true;
|
||||
|
||||
@Override
|
||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||
ParameterConfig config = (ParameterConfig) msParameter;
|
||||
|
|
|
@ -11,12 +11,16 @@ import io.metersphere.api.dto.definition.request.ElementUtil;
|
|||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
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.processors.post.MsJSR223PostProcessor;
|
||||
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
|
||||
import io.metersphere.api.dto.scenario.Body;
|
||||
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.CommonConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
||||
import io.metersphere.api.dto.ssl.KeyStoreConfig;
|
||||
import io.metersphere.api.dto.ssl.KeyStoreFile;
|
||||
import io.metersphere.api.dto.ssl.MsKeyStore;
|
||||
|
@ -156,7 +160,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
if (proxy != null) {
|
||||
if (StringUtils.equals(this.getRefType(), "CASE")) {
|
||||
ElementUtil.mergeHashTree(this.getHashTree(), proxy.getHashTree());
|
||||
}else {
|
||||
} else {
|
||||
this.setHashTree(proxy.getHashTree());
|
||||
}
|
||||
this.setMethod(proxy.getMethod());
|
||||
|
@ -272,6 +276,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
|
||||
addCertificate(config, httpSamplerTree);
|
||||
|
||||
//根据配置增加全局前后至脚本
|
||||
if (httpConfig != null) {
|
||||
this.setScript(httpConfig, httpSamplerTree, config, false);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
for (MsTestElement el : hashTree) {
|
||||
if (el.getEnvironmentId() == null) {
|
||||
|
@ -285,6 +294,49 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
}
|
||||
}
|
||||
|
||||
//根据配置增加全局前后至脚本
|
||||
if (httpConfig != null) {
|
||||
this.setScript(httpConfig, httpSamplerTree, config, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setScript(HttpConfig httpConfig, HashTree httpSamplerTree, ParameterConfig config, boolean isAfterPrivateScript) {
|
||||
MsJSR223PreProcessor preProcessor = httpConfig.getPreProcessor();
|
||||
MsJSR223PostProcessor postProcessor = httpConfig.getPostProcessor();
|
||||
GlobalScriptConfig globalScriptConfig = httpConfig.getGlobalScriptConfig();
|
||||
List<String> filterPreProtocal = globalScriptConfig == null ? new ArrayList<>() : globalScriptConfig.getFilterRequestPreScript();
|
||||
List<String> filterPostProtocal = globalScriptConfig == null ? new ArrayList<>() : globalScriptConfig.getFilterRequestPostScript();
|
||||
|
||||
boolean filterPre = filterPreProtocal.contains(GlobalScriptFilterRequest.HTTP.name());
|
||||
boolean filterPost = filterPostProtocal.contains(GlobalScriptFilterRequest.HTTP.name());
|
||||
|
||||
boolean isPreScriptExecAfterPrivateScript = globalScriptConfig == null ? false : globalScriptConfig.isPreScriptExecAfterPrivateScript();
|
||||
boolean isPostScriptExecAfterPrivateScript = globalScriptConfig == null ? false : globalScriptConfig.isPostScriptExecAfterPrivateScript();
|
||||
|
||||
if (!filterPre && preProcessor != null && StringUtils.isNotEmpty(preProcessor.getScript())) {
|
||||
if ((isPreScriptExecAfterPrivateScript && isAfterPrivateScript) || (!isPreScriptExecAfterPrivateScript && !isAfterPrivateScript)) {
|
||||
if (preProcessor.getEnvironmentId() == null) {
|
||||
if (this.getEnvironmentId() == null) {
|
||||
preProcessor.setEnvironmentId(useEnvironment);
|
||||
} else {
|
||||
preProcessor.setEnvironmentId(this.getEnvironmentId());
|
||||
}
|
||||
}
|
||||
preProcessor.toHashTree(httpSamplerTree, preProcessor.getHashTree(), config);
|
||||
}
|
||||
}
|
||||
if (!filterPost && postProcessor != null && StringUtils.isNotEmpty(postProcessor.getScript())) {
|
||||
if ((isPostScriptExecAfterPrivateScript && isAfterPrivateScript) || (!isPostScriptExecAfterPrivateScript && !isAfterPrivateScript)) {
|
||||
if (postProcessor.getEnvironmentId() == null) {
|
||||
if (this.getEnvironmentId() == null) {
|
||||
postProcessor.setEnvironmentId(useEnvironment);
|
||||
} else {
|
||||
postProcessor.setEnvironmentId(this.getEnvironmentId());
|
||||
}
|
||||
}
|
||||
postProcessor.toHashTree(httpSamplerTree, postProcessor.getHashTree(), config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initConnectAndResponseTimeout(ParameterConfig config) {
|
||||
|
@ -331,6 +383,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
this.setEnvironmentId(useEvnId);
|
||||
}
|
||||
HttpConfig httpConfig = matchConfig(config);
|
||||
httpConfig.setPreProcessor(environmentConfig.getPreProcessor());
|
||||
httpConfig.setPostProcessor(environmentConfig.getPostProcessor());
|
||||
httpConfig.setGlobalScriptConfig(environmentConfig.getGlobalScriptConfig());
|
||||
return httpConfig;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,13 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
|
||||
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
|
||||
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.GlobalScriptConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.api.service.ApiTestCaseService;
|
||||
import io.metersphere.api.service.ApiTestEnvironmentService;
|
||||
|
@ -37,6 +41,7 @@ import org.apache.jmeter.save.SaveService;
|
|||
import org.apache.jmeter.testelement.TestElement;
|
||||
import org.apache.jorphan.collections.HashTree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -148,40 +153,60 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
tree.add(arguments);
|
||||
}
|
||||
|
||||
// MsJSR223PreProcessor preProcessor = null;
|
||||
// MsJSR223PostProcessor postProcessor = null;
|
||||
// if(envConfig != null){
|
||||
// preProcessor = envConfig.getPreProcessor();
|
||||
// postProcessor = envConfig.getPostProcessor();
|
||||
// }
|
||||
//
|
||||
// //增加全局前后至脚本
|
||||
// if(preProcessor != null){
|
||||
// if (preProcessor.getEnvironmentId() == null) {
|
||||
// if (this.getEnvironmentId() == null) {
|
||||
// preProcessor.setEnvironmentId(useEnvironment);
|
||||
// } else {
|
||||
// preProcessor.setEnvironmentId(this.getEnvironmentId());
|
||||
// }
|
||||
// }
|
||||
// preProcessor.toHashTree(samplerHashTree, preProcessor.getHashTree(), config);
|
||||
// }
|
||||
// if(postProcessor != null){
|
||||
// if (postProcessor.getEnvironmentId() == null) {
|
||||
// if (this.getEnvironmentId() == null) {
|
||||
// postProcessor.setEnvironmentId(useEnvironment);
|
||||
// } else {
|
||||
// postProcessor.setEnvironmentId(this.getEnvironmentId());
|
||||
// }
|
||||
// }
|
||||
// postProcessor.toHashTree(samplerHashTree, postProcessor.getHashTree(), config);
|
||||
// }
|
||||
MsJSR223PreProcessor preProcessor = null;
|
||||
MsJSR223PostProcessor postProcessor = null;
|
||||
GlobalScriptConfig globalScriptConfig = null;
|
||||
if(envConfig != null){
|
||||
preProcessor = envConfig.getPreProcessor();
|
||||
postProcessor = envConfig.getPostProcessor();
|
||||
globalScriptConfig = envConfig.getGlobalScriptConfig();
|
||||
}
|
||||
boolean isPreScriptExecAfterPrivateScript = globalScriptConfig == null? false : globalScriptConfig.isPreScriptExecAfterPrivateScript();
|
||||
boolean isPostScriptExecAfterPrivateScript = globalScriptConfig == null? false : globalScriptConfig.isPostScriptExecAfterPrivateScript();
|
||||
boolean globalPreScriptIsFilter = false;
|
||||
boolean globalPostScriptIsFilter = false;
|
||||
List<String> preFilterProtocal = globalScriptConfig == null? new ArrayList<>() : globalScriptConfig.getFilterRequestPreScript();
|
||||
List<String> postFilterProtocal = globalScriptConfig == null? new ArrayList<>() : globalScriptConfig.getFilterRequestPostScript();
|
||||
if(preFilterProtocal.contains(GlobalScriptFilterRequest.JDBC.name())){
|
||||
globalPreScriptIsFilter = true;
|
||||
}
|
||||
if(postFilterProtocal.contains(GlobalScriptFilterRequest.JDBC.name())){
|
||||
globalPostScriptIsFilter = true;
|
||||
}
|
||||
|
||||
if(!isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter){
|
||||
this.addItemHashTree(preProcessor,samplerHashTree,config);
|
||||
}
|
||||
if(!isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter){
|
||||
this.addItemHashTree(postProcessor,samplerHashTree,config);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(samplerHashTree, el.getHashTree(), config);
|
||||
});
|
||||
}
|
||||
|
||||
if(isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter){
|
||||
this.addItemHashTree(preProcessor,samplerHashTree,config);
|
||||
}
|
||||
if(isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter){
|
||||
this.addItemHashTree(postProcessor,samplerHashTree,config);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addItemHashTree(MsTestElement element, HashTree samplerHashTree,ParameterConfig config){
|
||||
if(element != null){
|
||||
if (element.getEnvironmentId() == null) {
|
||||
if (this.getEnvironmentId() == null) {
|
||||
element.setEnvironmentId(useEnvironment);
|
||||
} else {
|
||||
element.setEnvironmentId(this.getEnvironmentId());
|
||||
}
|
||||
}
|
||||
element.toHashTree(samplerHashTree, element.getHashTree(), config);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDataSource(List<DatabaseConfig> databaseConfigs) {
|
||||
|
|
|
@ -11,9 +11,12 @@ import io.metersphere.api.dto.automation.EsbDataStruct;
|
|||
import io.metersphere.api.dto.automation.TcpTreeTableDataStruct;
|
||||
import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||
import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
|
||||
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
|
||||
import io.metersphere.api.dto.scenario.KeyValue;
|
||||
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptConfig;
|
||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptFilterRequest;
|
||||
import io.metersphere.api.service.ApiDefinitionService;
|
||||
import io.metersphere.api.service.ApiTestCaseService;
|
||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||
|
@ -148,13 +151,60 @@ public class MsTCPSampler extends MsTestElement {
|
|||
samplerHashTree.add(tcpPreProcessor.getJSR223PreProcessor());
|
||||
}
|
||||
|
||||
MsJSR223PreProcessor preProcessor = null;
|
||||
MsJSR223PostProcessor postProcessor = null;
|
||||
GlobalScriptConfig globalScriptConfig = null;
|
||||
if(envConfig != null){
|
||||
preProcessor = envConfig.getPreProcessor();
|
||||
postProcessor = envConfig.getPostProcessor();
|
||||
globalScriptConfig = envConfig.getGlobalScriptConfig();
|
||||
}
|
||||
|
||||
boolean isPreScriptExecAfterPrivateScript = globalScriptConfig == null? false : globalScriptConfig.isPreScriptExecAfterPrivateScript();
|
||||
boolean isPostScriptExecAfterPrivateScript = globalScriptConfig == null? false : globalScriptConfig.isPostScriptExecAfterPrivateScript();
|
||||
boolean globalPreScriptIsFilter = false;
|
||||
boolean globalPostScriptIsFilter = false;
|
||||
List<String> preFilterProtocal = globalScriptConfig == null? new ArrayList<>() : globalScriptConfig.getFilterRequestPreScript();
|
||||
List<String> postFilterProtocal = globalScriptConfig == null? new ArrayList<>() : globalScriptConfig.getFilterRequestPostScript();
|
||||
if(preFilterProtocal.contains(GlobalScriptFilterRequest.TCP.name())){
|
||||
globalPreScriptIsFilter = true;
|
||||
}
|
||||
if(postFilterProtocal.contains(GlobalScriptFilterRequest.TCP.name())){
|
||||
globalPostScriptIsFilter = true;
|
||||
}
|
||||
|
||||
if(!isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter){
|
||||
this.addItemHashTree(preProcessor,samplerHashTree,config);
|
||||
}
|
||||
if(!isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter){
|
||||
this.addItemHashTree(postProcessor,samplerHashTree,config);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
hashTree.forEach(el -> {
|
||||
el.toHashTree(samplerHashTree, el.getHashTree(), config);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(isPreScriptExecAfterPrivateScript && !globalPreScriptIsFilter){
|
||||
this.addItemHashTree(preProcessor,samplerHashTree,config);
|
||||
}
|
||||
if(isPostScriptExecAfterPrivateScript && !globalPostScriptIsFilter){
|
||||
this.addItemHashTree(postProcessor,samplerHashTree,config);
|
||||
}
|
||||
}
|
||||
private void addItemHashTree(MsTestElement element, HashTree samplerHashTree,ParameterConfig config){
|
||||
if(element != null){
|
||||
if (element.getEnvironmentId() == null) {
|
||||
if (this.getEnvironmentId() == null) {
|
||||
element.setEnvironmentId(useEnvironment);
|
||||
} else {
|
||||
element.setEnvironmentId(this.getEnvironmentId());
|
||||
}
|
||||
}
|
||||
element.toHashTree(samplerHashTree, element.getHashTree(), config);
|
||||
}
|
||||
}
|
||||
private void setRefElement() {
|
||||
try {
|
||||
ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package io.metersphere.api.dto.scenario;
|
||||
|
||||
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
|
||||
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
|
||||
import io.metersphere.api.dto.scenario.environment.GlobalScriptConfig;
|
||||
import io.metersphere.base.domain.ApiModule;
|
||||
import io.metersphere.base.domain.ApiModuleExample;
|
||||
import io.metersphere.base.mapper.ApiModuleMapper;
|
||||
|
@ -22,9 +25,12 @@ public class HttpConfig {
|
|||
private boolean isMock;
|
||||
private List<HttpConfigCondition> conditions;
|
||||
private List<KeyValue> headers;
|
||||
|
||||
private MsJSR223PreProcessor preProcessor;
|
||||
private MsJSR223PostProcessor postProcessor;
|
||||
private GlobalScriptConfig globalScriptConfig;
|
||||
private ApiModuleMapper apiModuleMapper;
|
||||
|
||||
|
||||
public HttpConfig initHttpConfig(HttpConfigCondition configCondition) {
|
||||
HttpConfig config = new HttpConfig();
|
||||
config.isMock = this.isMock;
|
||||
|
|
|
@ -21,8 +21,14 @@ public class EnvironmentConfig {
|
|||
private List<DatabaseConfig> databaseConfigs;
|
||||
private TCPConfig tcpConfig;
|
||||
private KeyStoreConfig sslConfig;
|
||||
private MsJSR223Processor postProcessor;
|
||||
private MsJSR223Processor preProcessor;
|
||||
//全局前后置脚本(每个请求都跑一遍)
|
||||
private MsJSR223PreProcessor preProcessor;
|
||||
private MsJSR223PostProcessor postProcessor;
|
||||
//全局前后置脚本步骤(只在全部步骤都前后做处理)
|
||||
private MsJSR223Processor preStepProcessor;
|
||||
private MsJSR223Processor postStepProcessor;
|
||||
//全局前后置脚本都配置
|
||||
private GlobalScriptConfig globalScriptConfig;
|
||||
private JSONObject authManager;
|
||||
|
||||
public EnvironmentConfig() {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package io.metersphere.api.dto.scenario.environment;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class GlobalScriptConfig {
|
||||
//要过滤的请求
|
||||
private List<String> filterRequestPreScript;
|
||||
private List<String> filterRequestPostScript;
|
||||
//是否在请求自有脚本之后再执行
|
||||
private boolean isPreScriptExecAfterPrivateScript;
|
||||
private boolean isPostScriptExecAfterPrivateScript;
|
||||
//是否统计到场景中
|
||||
private boolean connScenarioPreScript;
|
||||
private boolean connScenarioPostScript;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.api.dto.scenario.environment;
|
||||
|
||||
public enum GlobalScriptFilterRequest {
|
||||
HTTP,TCP,JDBC
|
||||
}
|
|
@ -25,29 +25,49 @@
|
|||
<el-tab-pane :label="$t('commons.ssl.config')" name="ssl">
|
||||
<ms-environment-s-s-l-config :project-id="projectId" :ssl-config="environment.config.sslConfig" :is-read-only="isReadOnly"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('api_test.definition.request.all_pre_script')" name="prescript">
|
||||
<el-switch v-model="environment.config.preProcessor.connScenario" active-text="关联场景结果"
|
||||
style="margin: 5px 5px 5px 5px"/>
|
||||
<el-tooltip class="item" effect="dark" content="脚本步骤会统计到场景执行结果中,执行报错时会影响场景的最终执行结果" placement="right">
|
||||
<i class="el-icon-info"/>
|
||||
</el-tooltip>
|
||||
<!-- <el-tab-pane :label="$t('api_test.definition.request.all_pre_script')" name="prescript">-->
|
||||
<!-- <el-switch v-model="environment.config.preProcessor.connScenario" active-text="关联场景结果"-->
|
||||
<!-- style="margin: 5px 5px 5px 5px"/>-->
|
||||
<!-- <el-tooltip class="item" effect="dark" content="脚本步骤会统计到场景执行结果中,执行报错时会影响场景的最终执行结果" placement="right">-->
|
||||
<!-- <i class="el-icon-info"/>-->
|
||||
<!-- </el-tooltip>-->
|
||||
|
||||
<jsr233-processor-content v-if="isRefresh"
|
||||
:jsr223-processor="environment.config.preProcessor"
|
||||
:is-pre-processor="true"
|
||||
:is-read-only="isReadOnly"/>
|
||||
<!-- <jsr233-processor-content v-if="isRefresh"-->
|
||||
<!-- :jsr223-processor="environment.config.preProcessor"-->
|
||||
<!-- :is-pre-processor="true"-->
|
||||
<!-- :is-read-only="isReadOnly"/>-->
|
||||
<!-- </el-tab-pane>-->
|
||||
<el-tab-pane :label="$t('api_test.definition.request.all_pre_script')" name="prescript">
|
||||
<environment-global-script v-if="isRefresh && environment.config.globalScriptConfig && environment.config.preProcessor && environment.config.preStepProcessor"
|
||||
:filter-request.sync="environment.config.globalScriptConfig.filterRequestPreScript"
|
||||
:exec-after-private-script.sync="environment.config.globalScriptConfig.isPreScriptExecAfterPrivateScript"
|
||||
:conn-scenario.sync="environment.config.globalScriptConfig.connScenarioPreScript"
|
||||
:script-processor="environment.config.preProcessor"
|
||||
:scrpit-step-processor="environment.config.preStepProcessor"
|
||||
:is-pre-processor="true"
|
||||
:is-read-only="isReadOnly"
|
||||
@updateGlobalScript="updateGlobalScript"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('api_test.definition.request.all_post_script')" name="postscript">
|
||||
<el-switch v-model="environment.config.postProcessor.connScenario" active-text="关联场景结果"
|
||||
style="margin: 5px 5px 5px 5px"/>
|
||||
<el-tooltip class="item" effect="dark" content="脚本步骤会统计到场景执行结果中,执行报错时会影响场景的最终执行结果" placement="right">
|
||||
<i class="el-icon-info"/>
|
||||
</el-tooltip>
|
||||
<environment-global-script v-if="isRefresh && environment.config.globalScriptConfig && environment.config.postProcessor && environment.config.postStepProcessor"
|
||||
:filter-request.sync="environment.config.globalScriptConfig.filterRequestPostScript"
|
||||
:exec-after-private-script.sync="environment.config.globalScriptConfig.isPostScriptExecAfterPrivateScript"
|
||||
:conn-scenario.sync="environment.config.globalScriptConfig.connScenarioPostScript"
|
||||
:script-processor="environment.config.postProcessor"
|
||||
:scrpit-step-processor="environment.config.postStepProcessor"
|
||||
:is-pre-processor="false"
|
||||
:is-read-only="isReadOnly"
|
||||
@updateGlobalScript="updateGlobalScript"/>
|
||||
<!-- <el-switch v-model="environment.config.postProcessor.connScenario" active-text="关联场景结果"-->
|
||||
<!-- style="margin: 5px 5px 5px 5px"/>-->
|
||||
<!-- <el-tooltip class="item" effect="dark" content="脚本步骤会统计到场景执行结果中,执行报错时会影响场景的最终执行结果" placement="right">-->
|
||||
<!-- <i class="el-icon-info"/>-->
|
||||
<!-- </el-tooltip>-->
|
||||
|
||||
<jsr233-processor-content v-if="isRefresh"
|
||||
:jsr223-processor="environment.config.postProcessor"
|
||||
:is-pre-processor="false"
|
||||
:is-read-only="false"/>
|
||||
<!-- <jsr233-processor-content v-if="isRefresh"-->
|
||||
<!-- :jsr223-processor="environment.config.postProcessor"-->
|
||||
<!-- :is-pre-processor="false"-->
|
||||
<!-- :is-read-only="false"/>-->
|
||||
</el-tab-pane>
|
||||
<!-- 认证配置 -->
|
||||
<el-tab-pane :label="$t('api_test.definition.request.all_auth_config')" name="authConfig" v-if="isRefresh">
|
||||
|
@ -78,12 +98,11 @@
|
|||
import MsEnvironmentCommonConfig from "./EnvironmentCommonConfig";
|
||||
import MsEnvironmentSSLConfig from "./EnvironmentSSLConfig";
|
||||
import MsApiAuthConfig from "@/business/components/api/definition/components/auth/ApiAuthConfig";
|
||||
|
||||
import MsTcpConfig from "@/business/components/api/test/components/request/tcp/TcpConfig";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import Jsr233ProcessorContent from "@/business/components/api/automation/scenario/common/Jsr233ProcessorContent";
|
||||
import {createComponent} from "@/business/components/api/definition/components/jmeter/components";
|
||||
import {KeyValue} from "@/business/components/api/test/model/ScenarioModel";
|
||||
import EnvironmentGlobalScript from "@/business/components/api/test/components/environment/EnvironmentGlobalScript";
|
||||
|
||||
export default {
|
||||
name: "EnvironmentEdit",
|
||||
|
@ -94,6 +113,7 @@
|
|||
MsEnvironmentCommonConfig,
|
||||
MsEnvironmentHttpConfig,
|
||||
MsEnvironmentSSLConfig,
|
||||
EnvironmentGlobalScript,
|
||||
MsDatabaseConfig, MsApiHostTable, MsDialogFooter, MsApiKeyValue, MsApiScenarioVariables
|
||||
},
|
||||
props: {
|
||||
|
@ -123,22 +143,34 @@
|
|||
if(!this.environment.config.preProcessor){
|
||||
this.environment.config.preProcessor = createComponent("JSR223PreProcessor");
|
||||
}
|
||||
if(!this.environment.config.preProcessor.connScenario){
|
||||
this.environment.config.preProcessor.connScenario = false;
|
||||
}
|
||||
if(!this.environment.config.postProcessor){
|
||||
this.environment.config.postProcessor = createComponent("JSR223PostProcessor");
|
||||
}
|
||||
if(!this.environment.config.postProcessor.connScenario){
|
||||
this.environment.config.postProcessor.connScenario = false;
|
||||
if(!this.environment.config.preStepProcessor){
|
||||
this.environment.config.preStepProcessor = createComponent("JSR223PreProcessor");
|
||||
}
|
||||
if(!this.environment.config.postStepProcessor){
|
||||
this.environment.config.postStepProcessor = createComponent("JSR223PostProcessor");
|
||||
}
|
||||
if(!this.environment.config.globalScriptConfig){
|
||||
this.environment.config.globalScriptConfig = {
|
||||
filterRequestPreScript:[],
|
||||
filterRequestPostScript:[],
|
||||
isPreScriptExecAfterPrivateScript:false,
|
||||
isPostScriptExecAfterPrivateScript:false,
|
||||
connScenarioPreScript:false,
|
||||
connScenarioPostScript:false,
|
||||
};
|
||||
}
|
||||
// if(!this.environment.config.postProcessor.connScenario){
|
||||
// this.environment.config.postProcessor.connScenario = false;
|
||||
// }
|
||||
if(!this.environment.config.authManager){
|
||||
this.environment.config.authManager = {'hashTree':[]};
|
||||
}
|
||||
if(!this.environment.config.authManager.hashTree){
|
||||
this.environment.config.authManager.hashTree = [];
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
watch: {
|
||||
|
@ -155,11 +187,21 @@
|
|||
this.environment.config.postProcessor.script = "";
|
||||
}
|
||||
}
|
||||
if(!this.environment.config.preProcessor.connScenario){
|
||||
this.environment.config.preProcessor.connScenario = false;
|
||||
if(!this.environment.config.preStepProcessor){
|
||||
this.environment.config.preStepProcessor = createComponent("JSR223PreProcessor");
|
||||
}
|
||||
if(!this.environment.config.postProcessor.connScenario){
|
||||
this.environment.config.postProcessor.connScenario = false;
|
||||
if(!this.environment.config.postStepProcessor){
|
||||
this.environment.config.postStepProcessor = createComponent("JSR223PostProcessor");
|
||||
}
|
||||
if(!this.environment.config.globalScriptConfig){
|
||||
this.environment.config.globalScriptConfig = {
|
||||
filterRequestPreScript:[],
|
||||
filterRequestPostScript:[],
|
||||
isPreScriptExecAfterPrivateScript:false,
|
||||
isPostScriptExecAfterPrivateScript:false,
|
||||
connScenarioPreScript:false,
|
||||
connScenarioPostScript:false,
|
||||
};
|
||||
}
|
||||
|
||||
if(!this.environment.config.authManager){
|
||||
|
@ -177,6 +219,25 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
updateGlobalScript(isPreScript,filedName,value){
|
||||
if(isPreScript){
|
||||
if(filedName === "connScenario"){
|
||||
this.environment.config.globalScriptConfig.connScenarioPreScript = value;
|
||||
}else if(filedName === "execAfterPrivateScript"){
|
||||
this.environment.config.globalScriptConfig.isPreScriptExecAfterPrivateScript = value;
|
||||
}else if(filedName === "filterRequest"){
|
||||
this.environment.config.globalScriptConfig.filterRequestPreScript = value;
|
||||
}
|
||||
}else {
|
||||
if(filedName === "connScenario"){
|
||||
this.environment.config.globalScriptConfig.connScenarioPostScript = value;
|
||||
}else if(filedName === "execAfterPrivateScript"){
|
||||
this.environment.config.globalScriptConfig.isPostScriptExecAfterPrivateScript = value;
|
||||
}else if(filedName === "filterRequest"){
|
||||
this.environment.config.globalScriptConfig.filterRequestPostScript = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
save() {
|
||||
this.$refs['environment'].validate((valid) => {
|
||||
if (valid && this.$refs.commonConfig.validate() && this.$refs.httpConfig.validate()) {
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-collapse v-model="activeNames">
|
||||
<el-collapse-item name="1">
|
||||
<template slot="title">
|
||||
单个请求步骤后执行
|
||||
<el-tooltip class="item" effect="dark" content="每一个API步骤后执行一次 如加解密" placement="right">
|
||||
<i class="el-icon-info"/>
|
||||
</el-tooltip>
|
||||
|
||||
<div class="header-right" style="margin: 5px 5px 5px 50px" @click.stop>
|
||||
过滤请求类型
|
||||
<el-select multiple v-model="filterRequestArray" style="margin : 0px 10px 0px 10px; width: 214px "
|
||||
size="small" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in requestArray"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
|
||||
脚本执行顺序
|
||||
<el-select v-model="isExecAfterPrivateScript" size="small" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in scriptExecSort"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<jsr233-processor-content :jsr223-processor="scriptProcessor"
|
||||
:is-pre-processor="isPreProcessor"
|
||||
:is-read-only="isReadOnly"/>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item name="2">
|
||||
<template slot="title">
|
||||
所有请求步骤后执行
|
||||
<el-tooltip class="item" effect="dark" content="全部API流程结束后执行一次 如token获取,场景初始化" placement="right">
|
||||
<i class="el-icon-info"/>
|
||||
</el-tooltip>
|
||||
<div class="header-right" style="margin: 5px 5px 5px 50px" @click.stop>
|
||||
<el-switch v-model="isConnScenario" active-text="关联场景结果"
|
||||
@click.stop/>
|
||||
<el-tooltip class="item" effect="dark" content="脚本步骤会统计到场景执行结果中,执行报错时会影响场景的最终执行结果" placement="right">
|
||||
<i class="el-icon-info"/>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<jsr233-processor-content :jsr223-processor="scrpitStepProcessor"
|
||||
:is-pre-processor="isPreProcessor"
|
||||
:is-read-only="isReadOnly"/>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import Jsr233ProcessorContent from "@/business/components/api/automation/scenario/common/Jsr233ProcessorContent";
|
||||
|
||||
export default {
|
||||
name: "EnvironmentGlobalScript",
|
||||
components: {
|
||||
Jsr233ProcessorContent,
|
||||
},
|
||||
props: {
|
||||
filterRequest: Array,
|
||||
execAfterPrivateScript: Boolean,
|
||||
connScenario: Boolean,
|
||||
|
||||
scriptProcessor: Object,
|
||||
scrpitStepProcessor: Object,
|
||||
isPreProcessor: Boolean,
|
||||
isReadOnly: Boolean,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
activeNames: [],
|
||||
isConnScenario: false,
|
||||
isExecAfterPrivateScript: false,
|
||||
filterRequestArray: [],
|
||||
requestArray: [
|
||||
{value: "HTTP", label: "HTTP"},
|
||||
{value: "TCP", label: "TCP"},
|
||||
{value: "JDBC", label: "JDBC"},
|
||||
],
|
||||
scriptExecSort: [],
|
||||
scriptPreExecSort: [
|
||||
{value: true, label: "步骤内前置脚本后"},
|
||||
{value: false, label: "步骤内前置脚本前"},
|
||||
],
|
||||
scriptPostExecSort: [
|
||||
{value: true, label: "步骤内后置脚本后"},
|
||||
{value: false, label: "步骤内后置脚本前"},
|
||||
],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.isPreProcessor) {
|
||||
this.scriptExecSort = this.scriptPreExecSort;
|
||||
} else {
|
||||
this.scriptExecSort = this.scriptPostExecSort;
|
||||
}
|
||||
this.isConnScenario = this.connScenario;
|
||||
this.isExecAfterPrivateScript = this.execAfterPrivateScript;
|
||||
this.filterRequestArray = this.filterRequest;
|
||||
if (this.scriptProcessor && this.scriptProcessor.script && this.scriptProcessor.script !== "") {
|
||||
this.activeNames.push("1");
|
||||
}
|
||||
if (this.scrpitStepProcessor && this.scrpitStepProcessor.script && this.scrpitStepProcessor.script !== "") {
|
||||
this.activeNames.push("2");
|
||||
}
|
||||
|
||||
},
|
||||
watch: {
|
||||
isConnScenario() {
|
||||
this.$emit("updateGlobalScript", this.isPreProcessor, "connScenario", this.isConnScenario);
|
||||
},
|
||||
isExecAfterPrivateScript() {
|
||||
this.$emit("updateGlobalScript", this.isPreProcessor, "execAfterPrivateScript", this.isExecAfterPrivateScript);
|
||||
},
|
||||
filterRequestArray() {
|
||||
this.$emit("updateGlobalScript", this.isPreProcessor, "filterRequest", this.filterRequestArray);
|
||||
},
|
||||
},
|
||||
methods: {},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.header-right {
|
||||
z-index: 1;
|
||||
}
|
||||
</style>
|
|
@ -103,12 +103,12 @@
|
|||
this.$refs.historyReport.initReportData();
|
||||
});
|
||||
},
|
||||
initPic(loadOption,tableData){
|
||||
initPic(loadOptionParam,tableData){
|
||||
this.loading = true;
|
||||
if (loadOption) {
|
||||
this.loadOption.legend = loadOption.legend;
|
||||
this.loadOption.xAxis = loadOption.xAxis;
|
||||
this.loadOption.series = loadOption.series;
|
||||
if (loadOptionParam) {
|
||||
this.loadOption.legend = loadOptionParam.legend;
|
||||
this.loadOption.xAxis = loadOptionParam.xaxis;
|
||||
this.loadOption.series = loadOptionParam.series;
|
||||
this.loadOption.grid = {
|
||||
bottom: '75px',//距离下边距
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue