From e5ffb7e2954b7e085f3e981ae5c19aa954dcb491 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 22 Aug 2022 10:36:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AA=E7=8E=AF=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=BB=93=E6=9E=9C=E5=A4=84=E7=90=86=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1016052 --user=赵勇 [接口测试]接口场景中循环控制器使用csv 变量while循环调试除了“不等于”条件,其他都失败 https://www.tapd.cn/55049933/s/1228643 --- .../scenario/component/LoopController.vue | 57 ++++++++++++------- frontend/src/i18n/en-US.js | 2 +- frontend/src/i18n/zh-CN.js | 2 +- frontend/src/i18n/zh-TW.js | 2 +- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index e8f3aac5be..772142939a 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -17,7 +17,7 @@
@@ -90,6 +90,7 @@ import ApiResponseComponent from "./ApiResponseComponent"; import MsRun from "../DebugRun"; import {getUUID} from "@/common/js/utils"; import {STEP} from "../Setting"; +import {getReportMessageSocket} from "@/business/components/api/automation/api-automation"; export default { name: "MsLoopController", @@ -167,6 +168,7 @@ export default { }, stepFilter: new STEP, messageWebSocket: {}, + uuid: "", }; }, watch: { @@ -176,16 +178,15 @@ export default { }, methods: { initMessageSocket() { - let protocol = "ws://"; - if (window.location.protocol === 'https:') { - protocol = "wss://"; - } - const uri = protocol + window.location.host + "/ws/" + this.reportId; - this.requestResult = new Map(); - this.messageWebSocket = new WebSocket(uri); + this.uuid = getUUID(); + this.messageWebSocket = getReportMessageSocket(this.uuid); this.messageWebSocket.onmessage = this.onDebugMessage; }, onDebugMessage(e) { + // 确认连接建立成功,开始执行 + if (e && e.data === "CONN_SUCCEEDED") { + this.runDebug(); + } if (e.data && e.data.startsWith("result_")) { let data = JSON.parse(e.data.substring(7)); this.debugCode(data); @@ -199,14 +200,28 @@ export default { this.loading = false; this.node.expanded = true; this.messageWebSocket.close(); - // 把请求结果分给各个请求 + // // 把请求结果分给各个请求 this.setResult(this.controller.hashTree); this.$store.state.currentApiCase = {debugLoop: getUUID()}; this.reload(); } }, - debugCode(data){ - if(data && this.node && this.node.data) { + clear(hashTree) { + if (hashTree) { + hashTree.forEach((item) => { + if (this.stepFilter.get("AllSamplerProxy").indexOf(item.type) !== -1) { + item.requestResult = []; + item.result = undefined; + item.code = undefined; + } + if (item.hashTree && item.hashTree.length > 0) { + this.setResult(item.hashTree); + } + }); + } + }, + debugCode(data) { + if (data && this.node && this.node.data) { if (data.error > 0) { this.node.data.code = "error"; } else { @@ -259,8 +274,7 @@ export default { } } }, - - runDebug() { + conn() { if (!this.controller.hashTree || this.controller.hashTree.length < 1) { this.$warning("当前循环下没有请求,不能执行"); return; @@ -269,11 +283,17 @@ export default { this.$warning(this.$t('api_test.automation.debug_message')); return; } + this.requestResult.clear(); + this.clear(this.controller.hashTree); + this.initMessageSocket(); + }, + runDebug() { this.loading = true; let currentEnvironmentId; + let resourceId = this.currentScenario.id + "_" + this.controller.projectId; if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map - && this.$store.state.scenarioEnvMap.has((this.currentScenario.id + "_" + this.controller.projectId))) { - currentEnvironmentId = this.$store.state.scenarioEnvMap.get((this.currentScenario.id + "_" + this.controller.projectId)); + && this.$store.state.scenarioEnvMap.has(resourceId)) { + currentEnvironmentId = this.$store.state.scenarioEnvMap.get(resourceId); } this.debugData = { id: this.currentScenario.id, @@ -289,8 +309,8 @@ export default { if (this.node && this.node.data) { this.node.data.debug = true; } - this.reportId = getUUID().substring(0, 8); - this.node.data.code=""; + this.reportId = this.uuid; + this.node.data.code = ""; this.node.data.testing = false; this.node.data.debug = true; }, @@ -324,7 +344,6 @@ export default { }); }, runRefresh() { - this.initMessageSocket(); }, errorRefresh() { this.loading = false; @@ -332,7 +351,7 @@ export default { setResult(hashTree) { if (hashTree) { hashTree.forEach((item) => { - if (item.type === "HTTPSamplerProxy" || item.type === "DubboSampler" || item.type === "JDBCSampler" || item.type === "TCPSampler") { + if (this.stepFilter.get("AllSamplerProxy").indexOf(item.type) !== -1 && this.requestResult.has(item.id)) { item.activeName = "0"; item.active = true; item.requestResult = this.requestResult.get(item.id); diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index dd0338a76f..ec4aa1597e 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -961,7 +961,7 @@ export default { test_execute_again: 'Test Execute Again', export: 'Export', export_to_ms_format: 'Export to MeterSphere format', - export_jmeter_format: 'Export to Jmeter format', + export_jmeter_format: 'Export to JMeter format', export_to_swagger3_format: 'Export to Swagger3.0 format', compare: 'Compare', generation_error: 'Report generation error, unable to view, please check log details!', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index b4bde4ef2c..8a30820b1a 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -965,7 +965,7 @@ export default { downloadZipFile: '下载执行文件', export: '导出', export_to_ms_format: '导出 MeterSphere 格式', - export_jmeter_format: '导出 Jmeter 格式', + export_jmeter_format: '导出 JMeter 格式', export_to_swagger3_format: '导出 Swagger3.0 格式', compare: '报告对比', generation_error: '报告生成错误, 无法查看, 请检查日志详情!', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 2a93b21073..b1a0642693 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -965,7 +965,7 @@ export default { downloadZipFile: '下載執行文件', export: '導出', export_to_ms_format: '導出 MeterSphere 格式', - export_jmeter_format: '導出 Jmeter 格式', + export_jmeter_format: '導出 JMeter 格式', export_to_swagger3_format: '導出 Swagger3.0 格式', compare: '報告對比', generation_error: '報告生成錯誤, 無法查看, 請檢查日誌詳情!',