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://", "");
|
String hostDomain = host.getDomain().trim().replace("http://", "").replace("https://", "");
|
||||||
if (StringUtils.equals(hostDomain, domain)) {
|
if (StringUtils.equals(hostDomain, domain)) {
|
||||||
dnsMap.put(hostDomain, host.getIp());
|
dnsMap.put(hostDomain, host.getIp());
|
||||||
|
}else if(StringUtils.startsWith(hostDomain,domain+":")){
|
||||||
|
dnsMap.put(domain,StringUtils.replace(hostDomain,domain,host.getIp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -216,12 +216,24 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
if (config.isOperating() && config.isEffective(this.getProjectId()) && config.getConfig().get(this.getProjectId()).getCommonConfig() != null
|
if (config.isOperating() && config.isEffective(this.getProjectId()) && config.getConfig().get(this.getProjectId()).getCommonConfig() != null
|
||||||
&& config.getConfig().get(this.getProjectId()).getCommonConfig().isEnableHost()) {
|
&& config.getConfig().get(this.getProjectId()).getCommonConfig().isEnableHost()) {
|
||||||
//导出的需要将DNSCache去掉,并把域名进行ip替换
|
//导出的需要将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();
|
String domain = sampler.getDomain();
|
||||||
if(dnsMap.containsKey(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));
|
sampler.setDomain(dnsMap.get(domain));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
final HashTree httpSamplerTree = tree.add(sampler);
|
final HashTree httpSamplerTree = tree.add(sampler);
|
||||||
|
|
||||||
// 注意顺序,放在config前面,会优先于环境的请求头生效
|
// 注意顺序,放在config前面,会优先于环境的请求头生效
|
||||||
|
|
Loading…
Reference in New Issue