feat(接口测试): 增加dubbo请求的前后置脚本设置
--bug=1012658 --user=宋天阳 【接口测试】dubbo协议-运行环境添加的全局后置脚本设置打印log不生效 https://www.tapd.cn/55049933/s/1146802
This commit is contained in:
parent
36d0236347
commit
26c47c15fa
|
@ -12,12 +12,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample;
|
import io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample;
|
||||||
import io.github.ningyu.jmeter.plugin.dubbo.sample.MethodArgument;
|
import io.github.ningyu.jmeter.plugin.dubbo.sample.MethodArgument;
|
||||||
import io.github.ningyu.jmeter.plugin.util.Constants;
|
import io.github.ningyu.jmeter.plugin.util.Constants;
|
||||||
|
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.sampler.dubbo.MsConfigCenter;
|
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsConfigCenter;
|
||||||
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsConsumerAndService;
|
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsConsumerAndService;
|
||||||
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsRegistryCenter;
|
import io.metersphere.api.dto.definition.request.sampler.dubbo.MsRegistryCenter;
|
||||||
import io.metersphere.api.dto.scenario.KeyValue;
|
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.service.ApiDefinitionService;
|
import io.metersphere.api.service.ApiDefinitionService;
|
||||||
import io.metersphere.api.service.ApiTestCaseService;
|
import io.metersphere.api.service.ApiTestCaseService;
|
||||||
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
import io.metersphere.base.domain.ApiDefinitionWithBLOBs;
|
||||||
|
@ -100,12 +103,32 @@ public class MsDubboSampler extends MsTestElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashTree testPlanTree = tree.add(dubboSample(config));
|
final HashTree testPlanTree = tree.add(dubboSample(config));
|
||||||
|
|
||||||
|
//添加全局前后置脚本
|
||||||
|
EnvironmentConfig envConfig = null;
|
||||||
|
if (config.getConfig() != null) {
|
||||||
|
envConfig = config.getConfig().get(this.getProjectId());
|
||||||
|
}
|
||||||
|
//处理全局前后置脚本(步骤内)
|
||||||
|
String environmentId = this.getEnvironmentId();
|
||||||
|
if (environmentId == null) {
|
||||||
|
if(StringUtils.isEmpty(this.useEnvironment) && envConfig != null){
|
||||||
|
environmentId = envConfig.getApiEnvironmentid();
|
||||||
|
}else {
|
||||||
|
environmentId = this.useEnvironment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//根据配置将脚本放置在私有脚本之前
|
||||||
|
JMeterScriptUtil.setScriptByEnvironmentConfig(envConfig, testPlanTree, GlobalScriptFilterRequest.DUBBO.name(), environmentId, config, false);
|
||||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||||
hashTree = ElementUtil.order(hashTree);
|
hashTree = ElementUtil.order(hashTree);
|
||||||
hashTree.forEach(el -> {
|
hashTree.forEach(el -> {
|
||||||
el.toHashTree(testPlanTree, el.getHashTree(), config);
|
el.toHashTree(testPlanTree, el.getHashTree(), config);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//根据配置将脚本放置在私有脚本之后
|
||||||
|
JMeterScriptUtil.setScriptByEnvironmentConfig(envConfig, testPlanTree, GlobalScriptFilterRequest.DUBBO.name(), environmentId, config, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setRefElement() {
|
private boolean setRefElement() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package io.metersphere.api.dto.scenario.environment;
|
package io.metersphere.api.dto.scenario.environment;
|
||||||
|
|
||||||
public enum GlobalScriptFilterRequest {
|
public enum GlobalScriptFilterRequest {
|
||||||
HTTP,TCP,JDBC
|
HTTP,TCP,JDBC,DUBBO
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ export default {
|
||||||
{value: "HTTP", label: "HTTP"},
|
{value: "HTTP", label: "HTTP"},
|
||||||
{value: "TCP", label: "TCP"},
|
{value: "TCP", label: "TCP"},
|
||||||
{value: "JDBC", label: "JDBC"},
|
{value: "JDBC", label: "JDBC"},
|
||||||
|
{value: "DUBBO", label: "DUBBO"},
|
||||||
],
|
],
|
||||||
scriptExecSort: [],
|
scriptExecSort: [],
|
||||||
scriptPreExecSort: [
|
scriptPreExecSort: [
|
||||||
|
|
Loading…
Reference in New Issue