From fa457c1aa811daae3a66041b73461afe57c968ec Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 1 Feb 2021 20:07:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20TCP=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsTestElement.java | 2 ++ .../dto/definition/request/sampler/MsTCPSampler.java | 10 +++++++++- .../api/automation/scenario/component/ApiComponent.vue | 1 + .../components/api/definition/ApiDefinition.vue | 1 - 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index b328123763..3efb220d8a 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -98,6 +98,8 @@ public abstract class MsTestElement { private String refType; @JSONField(ordinal = 10) private LinkedList hashTree; + @JSONField(ordinal = 11) + private boolean customizeReq; private MsTestElement parent; 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 50c790534b..0e0031ace9 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 @@ -12,6 +12,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.jmeter.config.Arguments; import org.apache.jmeter.config.ConfigTestElement; import org.apache.jmeter.modifiers.UserParameters; import org.apache.jmeter.protocol.tcp.sampler.TCPSampler; @@ -79,6 +80,13 @@ public class MsTCPSampler extends MsTestElement { } config.setConfig(getEnvironmentConfig(useEnvironment)); parseEnvironment(config.getConfig()); + + // 添加环境中的公共变量 + Arguments arguments = this.addArguments(config); + if (arguments != null) { + tree.add(this.addArguments(config)); + } + final HashTree samplerHashTree = new ListedHashTree(); samplerHashTree.add(tcpConfig()); tree.set(tcpSampler(config), samplerHashTree); @@ -94,7 +102,7 @@ public class MsTCPSampler extends MsTestElement { } private void parseEnvironment(EnvironmentConfig config) { - if (config != null && config.getTcpConfig() != null) { + if (!isCustomizeReq() && config != null && config.getTcpConfig() != null) { this.server = config.getTcpConfig().getServer(); this.port = config.getTcpConfig().getPort(); } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 0d16831558..bab86e7b27 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -235,6 +235,7 @@ this.loading = true; this.runData = []; this.request.useEnvironment = this.currentEnvironmentId; + this.request.customizeReq = this.isCustomizeReq; let debugData = { id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare, diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index b741e64efc..55ecc124b3 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -406,7 +406,6 @@ }, setNodeTree(data) { this.nodeTree = data; - console.log( this.nodeTree) }, changeSelectDataRangeAll(tableType) { this.$route.params.dataSelectRange = 'all';