fix(接口测试): 场景导出JMX时host转换增加带端口号域名的解析
场景导出JMX时host转换增加带端口号域名的解析
This commit is contained in:
parent
e606f28c1c
commit
fb9f992b60
|
@ -76,6 +76,8 @@ public class MsDNSCacheManager extends MsTestElement {
|
|||
String hostDomain = host.getDomain().trim().replace("http://", "").replace("https://", "");
|
||||
if (StringUtils.equals(hostDomain, domain)) {
|
||||
dnsMap.put(hostDomain, host.getIp());
|
||||
}else if(StringUtils.startsWith(hostDomain,domain+":")){
|
||||
dnsMap.put(domain,StringUtils.replace(hostDomain,domain,host.getIp()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -216,10 +216,22 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
if (config.isOperating() && config.isEffective(this.getProjectId()) && config.getConfig().get(this.getProjectId()).getCommonConfig() != null
|
||||
&& config.getConfig().get(this.getProjectId()).getCommonConfig().isEnableHost()) {
|
||||
//导出的需要将DNSCache去掉,并把域名进行ip替换
|
||||
Map<String,String> dnsMap = MsDNSCacheManager.getEnvironmentDns(config.getConfig().get(this.getProjectId()), httpConfig);
|
||||
Map<String, String> dnsMap = MsDNSCacheManager.getEnvironmentDns(config.getConfig().get(this.getProjectId()), httpConfig);
|
||||
String domain = sampler.getDomain();
|
||||
if(dnsMap.containsKey(domain)){
|
||||
sampler.setDomain(dnsMap.get(domain));
|
||||
if (dnsMap.containsKey(domain)) {
|
||||
String address = dnsMap.get(domain);
|
||||
if (address.contains(":")) {
|
||||
String[] addressArr = StringUtils.split(address, ":");
|
||||
if (addressArr.length == 2) {
|
||||
try {
|
||||
sampler.setDomain(addressArr[0]);
|
||||
sampler.setPort(Integer.parseInt(addressArr[1]));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sampler.setDomain(dnsMap.get(domain));
|
||||
}
|
||||
}
|
||||
}
|
||||
final HashTree httpSamplerTree = tree.add(sampler);
|
||||
|
@ -682,28 +694,28 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
list.stream().
|
||||
filter(KeyValue::isValid).
|
||||
filter(KeyValue::isEnable).forEach(keyValue -> {
|
||||
try {
|
||||
String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
|
||||
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value);
|
||||
if (keyValue.getValue() == null) {
|
||||
httpArgument.setValue("");
|
||||
}
|
||||
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
|
||||
if (StringUtils.isNotBlank(keyValue.getContentType())) {
|
||||
httpArgument.setContentType(keyValue.getContentType());
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(this.method, "get")) {
|
||||
if (StringUtils.isNotEmpty(httpArgument.getValue())) {
|
||||
arguments.addArgument(httpArgument);
|
||||
}
|
||||
} else {
|
||||
arguments.addArgument(httpArgument);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
|
||||
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value);
|
||||
if (keyValue.getValue() == null) {
|
||||
httpArgument.setValue("");
|
||||
}
|
||||
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
|
||||
if (StringUtils.isNotBlank(keyValue.getContentType())) {
|
||||
httpArgument.setContentType(keyValue.getContentType());
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(this.method, "get")) {
|
||||
if (StringUtils.isNotEmpty(httpArgument.getValue())) {
|
||||
arguments.addArgument(httpArgument);
|
||||
}
|
||||
} else {
|
||||
arguments.addArgument(httpArgument);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue