From ed24d9c0ca3a6375bde91565e72a4594dc29bec0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 1 Feb 2021 19:13:16 +0800 Subject: [PATCH 1/8] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8DCSV=E5=8F=98=E9=87=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsTestElement.java | 9 ++++----- .../io/metersphere/api/service/ApiAutomationService.java | 1 - 2 files changed, 4 insertions(+), 6 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..55bf1ad669 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 @@ -188,15 +188,14 @@ public abstract class MsTestElement { csvDataSet.setEnabled(true); csvDataSet.setProperty(TestElement.TEST_CLASS, CSVDataSet.class.getName()); csvDataSet.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); - csvDataSet.setName(item.getName()); - csvDataSet.setProperty("fileEncoding", item.getEncoding()); - csvDataSet.setProperty("variableNames", item.getName()); + csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName()); + csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding()); if (CollectionUtils.isNotEmpty(item.getFiles())) { csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()); } csvDataSet.setIgnoreFirstLine(false); csvDataSet.setProperty("delimiter", item.getDelimiter()); - csvDataSet.setComment(item.getDescription()); + csvDataSet.setComment(StringUtils.isEmpty(item.getDescription()) ? "" : item.getDescription()); tree.add(csvDataSet); }); } @@ -218,7 +217,7 @@ public abstract class MsTestElement { counterConfig.setVarName(item.getName()); counterConfig.setIncrement(item.getIncrement()); counterConfig.setFormat(item.getValue()); - counterConfig.setComment(item.getDescription()); + counterConfig.setComment(StringUtils.isEmpty(item.getDescription()) ? "" : item.getDescription()); tree.add(counterConfig); }); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 683c782918..e5c62f44b2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -507,7 +507,6 @@ public class ApiAutomationService { ParameterConfig config = new ParameterConfig(); config.setConfig(envConfig); HashTree hashTree = request.getTestElement().generateHashTree(config); - // 调用执行方法 createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(), SessionUtils.getUserId()); From 207d86554bd6c811001ad1a0d1937c6002764866 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 1 Feb 2021 19:24:32 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20IF=20=E9=9D=9E=E7=A9=BA=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/controller/MsIfController.java | 4 ++-- .../dto/definition/request/controller/MsLoopController.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index c9e995547c..acbfa04709 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -79,13 +79,13 @@ public class MsIfController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "empty(" + variable + ")"; + variable = "!empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "!empty(" + variable + ")"; + variable = "empty(" + variable + ")"; operator = ""; value = ""; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index e82c9b07bb..3d05319d2b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -123,13 +123,13 @@ public class MsLoopController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "empty(" + variable + ")"; + variable = "!empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "!empty(" + variable + ")"; + variable = "empty(" + variable + ")"; operator = ""; value = ""; } From fa457c1aa811daae3a66041b73461afe57c968ec Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 1 Feb 2021 20:07:12 +0800 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20TCP=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=AF=B7=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'; From acc2a27d699a61fab3a50be74912dc801ef2522b Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 1 Feb 2021 20:13:05 +0800 Subject: [PATCH 4/8] =?UTF-8?q?refactor:=20jar=E5=8C=85=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=A0=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/test/components/jar/JarConfig.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/business/components/api/test/components/jar/JarConfig.vue b/frontend/src/business/components/api/test/components/jar/JarConfig.vue index 3380217048..474401a3e4 100644 --- a/frontend/src/business/components/api/test/components/jar/JarConfig.vue +++ b/frontend/src/business/components/api/test/components/jar/JarConfig.vue @@ -72,4 +72,9 @@ From 0f67b6fc9fb04e594b6471db340e4e0cdeadfdf4 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 1 Feb 2021 20:22:15 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=BD=AC=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/common/js/utils.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js index 30602936cc..12f9460f3d 100644 --- a/frontend/src/common/js/utils.js +++ b/frontend/src/common/js/utils.js @@ -322,21 +322,23 @@ export function _getBodyUploadFiles(request, bodyUploadFiles, obj) { body = request.body; } if (body) { - body.kvs.forEach(param => { - if (param.files) { - param.files.forEach(item => { - if (item.file) { - if (!item.id) { - let fileId = getUUID().substring(0, 12); - item.name = item.file.name; - item.id = fileId; + if (body.kvs) { + body.kvs.forEach(param => { + if (param.files) { + param.files.forEach(item => { + if (item.file) { + if (!item.id) { + let fileId = getUUID().substring(0, 12); + item.name = item.file.name; + item.id = fileId; + } + obj.bodyUploadIds.push(item.id); + bodyUploadFiles.push(item.file); } - obj.bodyUploadIds.push(item.id); - bodyUploadFiles.push(item.file); - } - }); - } - }); + }); + } + }); + } if (body.binary) { body.binary.forEach(param => { if (param.files) { From eb97cbeb251ed9e159f5cf2258085fae15454ae1 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 1 Feb 2021 20:29:38 +0800 Subject: [PATCH 6/8] =?UTF-8?q?fix:=20=E6=89=B9=E9=87=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E7=8E=AF=E5=A2=83=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/api/service/ApiAutomationService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index e5c62f44b2..7e72e61f71 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -707,7 +707,9 @@ public class ApiAutomationService { apiScenarios.forEach(item -> { JSONObject object = JSONObject.parseObject(item.getScenarioDefinition()); object.put("environmentId", request.getEnvironmentId()); - item.setScenarioDefinition(JSONObject.toJSONString(object)); + if (object != null) { + item.setScenarioDefinition(JSONObject.toJSONString(object)); + } apiScenarioMapper.updateByPrimaryKeySelective(item); }); } From 141f69e374e24efbbdad003e5755e709085601db Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 2 Feb 2021 10:02:04 +0800 Subject: [PATCH 7/8] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8DDUBBO=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E8=B0=83=E8=AF=95=20method=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/definition/components/case/ApiCaseItem.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 021c0aaa71..c47ef1d9cd 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -263,6 +263,7 @@ }); }, saveCase(row) { + console.log(row) let tmp = JSON.parse(JSON.stringify(row)); this.isShowInput = false; if (this.validate(tmp)) { @@ -278,7 +279,9 @@ url = "/api/testcase/update"; } else { tmp.request.path = this.api.path; - tmp.request.method = this.api.method; + if (tmp.request.protocol != "dubbo://" && tmp.request.protocol != "DUBBO") { + tmp.request.method = this.api.method; + } } if (tmp.tags instanceof Array) { tmp.tags = JSON.stringify(tmp.tags); From 5272593a61b91699718fc6e61d2b364351877b3b Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 2 Feb 2021 10:03:26 +0800 Subject: [PATCH 8/8] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E5=AE=9A?= =?UTF-8?q?=E4=B9=89):=20=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99=20=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/definition/components/case/ApiCaseItem.vue | 1 - 1 file changed, 1 deletion(-) 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 c47ef1d9cd..0b983ea1c8 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -263,7 +263,6 @@ }); }, saveCase(row) { - console.log(row) let tmp = JSON.parse(JSON.stringify(row)); this.isShowInput = false; if (this.validate(tmp)) {