From 463dfaa463434509b067f48892c0a813c9382dbd Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 4 Mar 2022 14:29:54 +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=8DTCP=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008379 --user=宋天阳 【github#7974】tcp接口的请求时间和响应时间不起作用 https://www.tapd.cn/55049933/s/1113826 --- .../request/sampler/MsTCPSampler.java | 16 ++++- .../components/case/ApiCaseItem.vue | 70 +++++++++++++------ 2 files changed, 64 insertions(+), 22 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 8f6e55789f..a69480193e 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -227,7 +227,7 @@ public class MsTCPSampler extends MsTestElement { } private void parseEnvironment(EnvironmentConfig config) { - if (!isCustomizeReq() && config != null) { + if (!isCustomizeReq() && config != null && config.getTcpConfig() != null) { if (!isCustomizeReq() && config != null) { this.server = config.getTcpConfig().getServer(); this.port = config.getTcpConfig().getPort(); @@ -238,6 +238,14 @@ public class MsTCPSampler extends MsTestElement { this.eolByte = config.getTcpConfig().getEolByte(); } } + + if ((StringUtils.isEmpty(this.timeout) || StringUtils.equals(this.timeout, "0")) && StringUtils.isNotEmpty(config.getTcpConfig().getTimeout())) { + this.timeout = config.getTcpConfig().getTimeout(); + } + + if (StringUtils.isEmpty(this.ctimeout) || StringUtils.equals(this.ctimeout, "0") && StringUtils.isNotEmpty(config.getTcpConfig().getCtimeout())) { + this.ctimeout = config.getTcpConfig().getCtimeout(); + } } } } @@ -265,6 +273,12 @@ public class MsTCPSampler extends MsTestElement { tcpSampler.setCloseConnection(String.valueOf(this.isCloseConnection())); tcpSampler.setSoLinger(this.getSoLinger()); tcpSampler.setEolByte(this.getEolByte()); + if (StringUtils.isNotEmpty(this.timeout)) { + tcpSampler.setTimeout(this.timeout); + } + if (StringUtils.isNotEmpty(this.ctimeout)) { + tcpSampler.setConnectTimeout(this.ctimeout); + } String value = this.getRequest(); if (StringUtils.isNotEmpty(this.getConnectEncoding())) { diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index 5c9ee44c8d..b3d19cdb64 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -8,7 +8,7 @@ + :placeholder="$t('commons.input_name')" ref="nameEdit"/> {{ apiCase.id ? apiCase.name : '' | ellipsis }} @@ -17,7 +17,8 @@ - {{ $t('operating_log.change_history') }} + {{ $t('operating_log.change_history') }}
@@ -27,13 +28,15 @@
- + - {{ apiCase.request.method }} @@ -45,34 +48,42 @@ - +
- + - +
- +
- - +
STOP
@@ -85,10 +96,12 @@
- + {{ getResult(apiCase.execResult) }} - + {{ getResult(apiCase.execResult) }}
{{ getResult(apiCase.execResult) }}
@@ -110,22 +123,27 @@

{{ $t('api_test.definition.request.req_param') }}

- - - + + +

{{ $t('api_test.definition.request.res_param') }}

- +
- +
@@ -192,7 +210,7 @@ export default { ShowMoreBtn, MsChangeHistory, "esbDefinition": esbDefinition.default, - "esbDefinitionResponse": esbDefinitionResponse.default , + "esbDefinitionResponse": esbDefinitionResponse.default, ApiCaseHeader }, data() { @@ -324,7 +342,14 @@ export default { let uuid = getUUID(); let request = JSON.parse(JSON.stringify(data.request)); request.id = uuid; - let obj = {name: "copy_" + data.name, priority: data.priority, active: true, tags: data.tags, request: request, uuid: uuid}; + let obj = { + name: "copy_" + data.name, + priority: data.priority, + active: true, + tags: data.tags, + request: request, + uuid: uuid + }; this.$emit('copyCase', obj); } }, @@ -394,7 +419,10 @@ export default { stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type); } if (stepArray[i].type === "Assertions" && !stepArray[i].document) { - stepArray[i].document = {type: "JSON", data: {xmlFollowAPI: false, jsonFollowAPI: false, json: [], xml: []}}; + stepArray[i].document = { + type: "JSON", + data: {xmlFollowAPI: false, jsonFollowAPI: false, json: [], xml: []} + }; } if (stepArray[i] && stepArray[i].authManager && !stepArray[i].authManager.clazzName) { stepArray[i].authManager.clazzName = TYPE_TO_C.get(stepArray[i].authManager.type); @@ -479,7 +507,7 @@ export default { this.addModule(row); } else { this.api.source = "editCase"; - if (!this.isSave){ + if (!this.isSave) { this.saveCase(row, hideAlert); } }