Merge branch 'v1.3'

This commit is contained in:
fit2-zhao 2020-10-12 09:43:54 +08:00
commit 9e154c6d87
2 changed files with 321 additions and 326 deletions

View File

@ -70,18 +70,18 @@
</template> </template>
<script> <script>
import MsApiScenarioConfig from "./components/ApiScenarioConfig"; import MsApiScenarioConfig from "./components/ApiScenarioConfig";
import {Scenario, Test} from "./model/ScenarioModel" import {Scenario, Test} from "./model/ScenarioModel"
import MsApiReportStatus from "../report/ApiReportStatus"; import MsApiReportStatus from "../report/ApiReportStatus";
import MsApiReportDialog from "./ApiReportDialog"; import MsApiReportDialog from "./ApiReportDialog";
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils";
import MsScheduleConfig from "../../common/components/MsScheduleConfig"; import MsScheduleConfig from "../../common/components/MsScheduleConfig";
import ApiImport from "./components/import/ApiImport"; import ApiImport from "./components/import/ApiImport";
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent"; import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
import MsContainer from "@/business/components/common/components/MsContainer"; import MsContainer from "@/business/components/common/components/MsContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
export default { export default {
name: "MsApiTestConfig", name: "MsApiTestConfig",
components: { components: {
@ -392,26 +392,26 @@ export default {
beforeDestroy() { beforeDestroy() {
document.removeEventListener('keydown', this.handleEvent); document.removeEventListener('keydown', this.handleEvent);
} }
} }
</script> </script>
<style scoped> <style scoped>
.test-container { .test-container {
height: calc(100vh - 155px); height: calc(100vh - 155px);
min-height: 600px; min-height: 600px;
} }
.test-name { .test-name {
width: 600px; width: 600px;
margin-left: -20px; margin-left: -20px;
margin-right: 20px; margin-right: 20px;
} }
.test-project { .test-project {
min-width: 150px; min-width: 150px;
} }
.test-container .more { .test-container .more {
margin-left: 10px; margin-left: 10px;
} }
</style> </style>

View File

@ -1071,11 +1071,8 @@ class JMXGenerator {
this.addScenarioHeaders(threadGroup, scenario); this.addScenarioHeaders(threadGroup, scenario);
this.addScenarioCookieManager(threadGroup, scenario); this.addScenarioCookieManager(threadGroup, scenario);
// 放在计划或线程组中,不建议放具体某个请求中
this.addDNSCacheManager(threadGroup, scenario);
this.addJDBCDataSources(threadGroup, scenario); this.addJDBCDataSources(threadGroup, scenario);
scenario.requests.forEach(request => { scenario.requests.forEach(request => {
if (request.enable) { if (request.enable) {
if (!request.isValid()) return; if (!request.isValid()) return;
@ -1095,6 +1092,8 @@ class JMXGenerator {
sampler = new TCPSampler(request.name || "", request); sampler = new TCPSampler(request.name || "", request);
} }
this.addDNSCacheManager(sampler, scenario.environment, request.useEnvironment);
this.addRequestExtractor(sampler, request); this.addRequestExtractor(sampler, request);
this.addRequestAssertion(sampler, request); this.addRequestAssertion(sampler, request);
@ -1156,18 +1155,14 @@ class JMXGenerator {
} }
} }
addDNSCacheManager(threadGroup, scenario) { addDNSCacheManager(httpSamplerProxy, environment, useEnv) {
if (scenario.requests.length < 1) { if (environment && useEnv === true) {
return let commonConfig = environment.config.commonConfig;
}
let request = scenario.requests[0];
if (request.environment) {
let commonConfig = request.environment.config.commonConfig;
let hosts = commonConfig.hosts; let hosts = commonConfig.hosts;
if (commonConfig.enableHost && hosts.length > 0) { if (commonConfig.enableHost && hosts.length > 0) {
let name = request.name + " DNSCacheManager"; let name = " DNSCacheManager";
// 强化判断如果未匹配到合适的host则不开启DNSCache // 强化判断如果未匹配到合适的host则不开启DNSCache
let domain = request.environment.config.httpConfig.domain; let domain = environment.config.httpConfig.domain;
let validHosts = []; let validHosts = [];
hosts.forEach(item => { hosts.forEach(item => {
if (item.domain != undefined && domain != undefined) { if (item.domain != undefined && domain != undefined) {
@ -1179,7 +1174,7 @@ class JMXGenerator {
} }
}); });
if (validHosts.length > 0) { if (validHosts.length > 0) {
threadGroup.put(new DNSCacheManager(name, validHosts)); httpSamplerProxy.put(new DNSCacheManager(name, validHosts));
} }
} }
} }