From 90e857b10540251319efb162df2cb4d24612be10 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Sat, 10 Oct 2020 19:52:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20ho?= =?UTF-8?q?sts=20=E5=88=97=E8=A1=A8=E6=89=A7=E8=A1=8C=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/test/ApiTestConfig.vue | 626 +++++++++--------- .../api/test/model/ScenarioModel.js | 21 +- 2 files changed, 321 insertions(+), 326 deletions(-) diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index e76812463e..9c19a6666e 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -70,348 +70,348 @@ diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index d024dbdca5..7e6c44c8d6 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -1043,11 +1043,8 @@ class JMXGenerator { this.addScenarioHeaders(threadGroup, scenario); this.addScenarioCookieManager(threadGroup, scenario); - // 放在计划或线程组中,不建议放具体某个请求中 - this.addDNSCacheManager(threadGroup, scenario); this.addJDBCDataSources(threadGroup, scenario); - scenario.requests.forEach(request => { if (request.enable) { if (!request.isValid()) return; @@ -1065,6 +1062,8 @@ class JMXGenerator { sampler = new JDBCSampler(request.name || "", request); } + this.addDNSCacheManager(sampler, scenario.environment, request.useEnvironment); + this.addRequestExtractor(sampler, request); this.addRequestAssertion(sampler, request); @@ -1126,18 +1125,14 @@ class JMXGenerator { } } - addDNSCacheManager(threadGroup, scenario) { - if (scenario.requests.length < 1) { - return - } - let request = scenario.requests[0]; - if (request.environment) { - let commonConfig = request.environment.config.commonConfig; + addDNSCacheManager(httpSamplerProxy, environment, useEnv) { + if (environment && useEnv === true) { + let commonConfig = environment.config.commonConfig; let hosts = commonConfig.hosts; if (commonConfig.enableHost && hosts.length > 0) { - let name = request.name + " DNSCacheManager"; + let name = " DNSCacheManager"; // 强化判断,如果未匹配到合适的host则不开启DNSCache - let domain = request.environment.config.httpConfig.domain; + let domain = environment.config.httpConfig.domain; let validHosts = []; hosts.forEach(item => { if (item.domain != undefined && domain != undefined) { @@ -1149,7 +1144,7 @@ class JMXGenerator { } }); if (validHosts.length > 0) { - threadGroup.put(new DNSCacheManager(name, validHosts)); + httpSamplerProxy.put(new DNSCacheManager(name, validHosts)); } } }