fix(接口调试): 修复host不匹配时开启DnsCache缺陷
This commit is contained in:
parent
c0a9dc003d
commit
4d983fd071
|
@ -76,6 +76,7 @@ public class XmindToTestCaseParser {
|
|||
return jsonArray.toJSONString();
|
||||
}
|
||||
|
||||
// 初始化一个用例
|
||||
private void newTestCase(String title, String nodePath, List<Attached> attacheds) {
|
||||
TestCaseWithBLOBs testCase = new TestCaseWithBLOBs();
|
||||
testCase.setProjectId(projectId);
|
||||
|
@ -88,6 +89,7 @@ public class XmindToTestCaseParser {
|
|||
String tcArr[] = tc.split(":");
|
||||
if (tcArr.length != 2) {
|
||||
process.append(Translator.get("test_case_name") + "【 " + title + " 】" + Translator.get("incorrect_format"));
|
||||
return;
|
||||
}
|
||||
// 用例名称
|
||||
testCase.setName(tcArr[1].replace("tc:|tc:", ""));
|
||||
|
|
|
@ -530,17 +530,15 @@ export class HeaderManager extends DefaultTestElement {
|
|||
}
|
||||
|
||||
export class DNSCacheManager extends DefaultTestElement {
|
||||
constructor(testName, domain, hosts) {
|
||||
constructor(testName, hosts) {
|
||||
super('DNSCacheManager', 'DNSCachePanel', 'DNSCacheManager', testName);
|
||||
let collectionPropServers = this.collectionProp('DNSCacheManager.servers');
|
||||
let collectionPropHosts = this.collectionProp('DNSCacheManager.hosts');
|
||||
|
||||
hosts.forEach(host => {
|
||||
let elementProp = collectionPropHosts.elementProp(host.domain, 'StaticHost');
|
||||
if (host && host.domain.trim().indexOf(domain.trim()) != -1) {
|
||||
elementProp.stringProp('StaticHost.Name', host.domain);
|
||||
elementProp.stringProp('StaticHost.Address', host.ip);
|
||||
}
|
||||
elementProp.stringProp('StaticHost.Name', host.domain);
|
||||
elementProp.stringProp('StaticHost.Address', host.ip);
|
||||
});
|
||||
|
||||
let boolProp = this.boolProp('DNSCacheManager.isCustomResolver', true);
|
||||
|
|
|
@ -214,7 +214,12 @@ export class Scenario extends BaseConfig {
|
|||
this.databaseConfigs = [];
|
||||
|
||||
this.set(options);
|
||||
this.sets({variables: KeyValue, headers: KeyValue, requests: RequestFactory, databaseConfigs: DatabaseConfig}, options);
|
||||
this.sets({
|
||||
variables: KeyValue,
|
||||
headers: KeyValue,
|
||||
requests: RequestFactory,
|
||||
databaseConfigs: DatabaseConfig
|
||||
}, options);
|
||||
}
|
||||
|
||||
initOptions(options = {}) {
|
||||
|
@ -1046,11 +1051,20 @@ class JMXGenerator {
|
|||
if (request.environment) {
|
||||
let commonConfig = request.environment.config.commonConfig;
|
||||
let hosts = commonConfig.hosts;
|
||||
if (commonConfig.enableHost) {
|
||||
if (commonConfig.enableHost && hosts.length > 0) {
|
||||
let name = request.name + " DNSCacheManager";
|
||||
if (hosts.length > 0) {
|
||||
//let domain = request.environment.protocol + "://" + request.environment.domain;
|
||||
threadGroup.put(new DNSCacheManager(name, request.environment.config.httpConfig.domain, hosts));
|
||||
// 强化判断,如果未匹配到合适的host则不开启DNSCache
|
||||
let domain = request.environment.config.httpConfig.domain;
|
||||
let validHosts = [];
|
||||
hosts.forEach(item => {
|
||||
let d = item.domain.trim().replace("http://", "").replace("https://", "");
|
||||
if (item && d === domain.trim()) {
|
||||
item.domain = d; // 域名去掉协议
|
||||
validHosts.push(item);
|
||||
}
|
||||
});
|
||||
if (validHosts.length > 0) {
|
||||
threadGroup.put(new DNSCacheManager(name, validHosts));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue