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()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -219,9 +219,21 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
Map<String, String> dnsMap = MsDNSCacheManager.getEnvironmentDns(config.getConfig().get(this.getProjectId()), httpConfig);
|
||||
String domain = sampler.getDomain();
|
||||
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);
|
||||
|
||||
// 注意顺序,放在config前面,会优先于环境的请求头生效
|
||||
|
|
Loading…
Reference in New Issue