From 56a38525e4d740e1edcb5ba5c96fedf4d9f08002 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 24 Feb 2021 11:04:21 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/automation/scenario/common/ApiBaseComponent.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue index d6b4ebb9fd..624aeef9b4 100644 --- a/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/ApiBaseComponent.vue @@ -31,10 +31,10 @@ - + - + From eb16cead2ecfee0c6c1d67e01ac7cb03d169fb26 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 24 Feb 2021 14:03:00 +0800 Subject: [PATCH 2/7] =?UTF-8?q?style(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89)?= =?UTF-8?q?:=20=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=92=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=B7=E5=BC=8F=E9=97=B4=E8=B7=9D=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/definition/components/case/ApiCaseItem.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 cba4d8dd89..bd54431588 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -35,13 +35,13 @@
- - {{ apiCase.createTime | timestampFormatDate }} - {{ apiCase.createUser }} {{ $t('api_test.definition.request.create_info') }} - - {{ apiCase.updateTime | timestampFormatDate }} - {{ apiCase.updateUser }} {{ $t('api_test.definition.request.update_info') }} + {{ apiCase.createTime | timestampFormatDate }} + {{ apiCase.createUser }} {{ $t('api_test.definition.request.create_info') }} + + + {{ apiCase.updateTime | timestampFormatDate }} + {{ apiCase.updateUser }} {{ $t('api_test.definition.request.update_info') }}
From 723edcac2248a3f6c95f060167b029640f90ad6a Mon Sep 17 00:00:00 2001 From: BugKing Date: Wed, 24 Feb 2021 15:52:20 +0800 Subject: [PATCH 3/7] =?UTF-8?q?build:=20issue=20=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E6=8E=92=E9=99=A4=20plan=20=E6=A0=87?= =?UTF-8?q?=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/stale.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/stale.yml b/.github/stale.yml index 7525aae70b..a7e5a09541 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -7,6 +7,7 @@ exemptLabels: - lifecycle/frozen - pinned - security + - plan staleLabel: stale # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > From 80234b3b9132541ec9f574bc1c33f241237f3b2b Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 24 Feb 2021 16:08:57 +0800 Subject: [PATCH 4/7] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):=20=E5=8E=BB=E6=8E=89setupThreadGroup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xml/reader/jmx/JmeterDocumentParser.java | 83 ------------------- 1 file changed, 83 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java index 349563c8f2..8c956b18f5 100644 --- a/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java +++ b/backend/src/main/java/io/metersphere/performance/parse/xml/reader/jmx/JmeterDocumentParser.java @@ -89,7 +89,6 @@ public class JmeterDocumentParser implements DocumentParser { if (nodeNameEquals(ele, HASH_TREE_ELEMENT)) { parseHashTree(ele); } else if (nodeNameEquals(ele, TEST_PLAN)) { - processSetupTestPlan(ele); processCheckoutConfigTestElement(ele); processCheckoutDnsCacheManager(ele); processCheckoutArguments(ele); @@ -483,88 +482,6 @@ public class JmeterDocumentParser implements DocumentParser { } } - private void processSetupTestPlan(Element ele) { - Document document = ele.getOwnerDocument(); - Node hashTree = ele.getNextSibling(); - while (!(hashTree instanceof Element)) { - hashTree = hashTree.getNextSibling(); - } - - KafkaProperties kafkaProperties = CommonBeanFactory.getBean(KafkaProperties.class); - String bootstrapServers = kafkaProperties.getBootstrapServers(); - String[] servers = StringUtils.split(bootstrapServers, ","); - for (String s : servers) { - String[] ipAndPort = StringUtils.split(s, ":"); - Element setupElement = document.createElement("SetupThreadGroup"); - setupElement.setAttribute("guiclass", "SetupThreadGroupGui"); - setupElement.setAttribute("testclass", "SetupThreadGroup"); - setupElement.setAttribute("testname", "setUp Thread Group"); - setupElement.setAttribute("enabled", "true"); - setupElement.appendChild(createStringProp(document, "ThreadGroup.on_sample_error", "stoptestnow")); - Element elementProp = document.createElement("elementProp"); - elementProp.setAttribute("name", "ThreadGroup.main_controller"); - elementProp.setAttribute("elementType", "LoopController"); - elementProp.setAttribute("guiclass", "LoopControlPanel"); - elementProp.setAttribute("testclass", "LoopController"); - elementProp.setAttribute("testname", "Loop Controller"); - elementProp.setAttribute("enabled", "true"); - elementProp.appendChild(createBoolProp(document, "LoopController.continue_forever", false)); - elementProp.appendChild(createIntProp(document, "LoopController.loops", 1)); - setupElement.appendChild(elementProp); - setupElement.appendChild(createStringProp(document, "ThreadGroup.num_threads", "1")); - setupElement.appendChild(createStringProp(document, "ThreadGroup.ramp_time", "1")); - setupElement.appendChild(createStringProp(document, "ThreadGroup.duration", "")); - setupElement.appendChild(createStringProp(document, "ThreadGroup.delay", "")); - setupElement.appendChild(createBoolProp(document, "ThreadGroup.scheduler", false)); - setupElement.appendChild(createBoolProp(document, "ThreadGroup.same_user_on_next_iteration", true)); - hashTree.appendChild(setupElement); - - Element setupHashTree = document.createElement(HASH_TREE_ELEMENT); - - Element tcpSampler = document.createElement("TCPSampler"); - tcpSampler.setAttribute("guiclass", "TCPSamplerGui"); - tcpSampler.setAttribute("testclass", "TCPSampler"); - tcpSampler.setAttribute("testname", "TCP Sampler"); - tcpSampler.setAttribute("enabled", "true"); - tcpSampler.appendChild(createStringProp(document, "TCPSampler.classname", "TCPClientImpl")); - tcpSampler.appendChild(createStringProp(document, "TCPSampler.server", ipAndPort[0])); - tcpSampler.appendChild(createBoolProp(document, "TCPSampler.reUseConnection", true)); - tcpSampler.appendChild(createStringProp(document, "TCPSampler.port", ipAndPort[1])); - tcpSampler.appendChild(createBoolProp(document, "TCPSampler.nodelay", false)); - tcpSampler.appendChild(createStringProp(document, "TCPSampler.timeout", "100")); - tcpSampler.appendChild(createStringProp(document, "TCPSampler.ctimeout", "100")); - tcpSampler.appendChild(createStringProp(document, "TCPSampler.request", "1010")); - tcpSampler.appendChild(createBoolProp(document, "TCPSampler.closeConnection", false)); - tcpSampler.appendChild(createStringProp(document, "TCPSampler.EolByte", "0")); - tcpSampler.appendChild(createStringProp(document, "ConfigTestElement.username", "")); - tcpSampler.appendChild(createStringProp(document, "ConfigTestElement.password", "")); - - Element tcpSamplerHashTree = document.createElement(HASH_TREE_ELEMENT); - - Element responseAssertion = document.createElement("ResponseAssertion"); - responseAssertion.setAttribute("guiclass", "AssertionGui"); - responseAssertion.setAttribute("testclass", "ResponseAssertion"); - responseAssertion.setAttribute("testname", "Response Assertion"); - responseAssertion.setAttribute("enabled", "true"); - Element collectionProp = document.createElement("collectionProp"); - collectionProp.setAttribute("name", "Asserion.test_strings"); - collectionProp.appendChild(createStringProp(document, "49586", "200")); - responseAssertion.appendChild(collectionProp); - responseAssertion.appendChild(createStringProp(document, "Assertion.custom_message", "")); - responseAssertion.appendChild(createStringProp(document, "Assertion.test_field", "Assertion.response_code")); - responseAssertion.appendChild(createBoolProp(document, "Assertion.assume_success", false)); - responseAssertion.appendChild(createIntProp(document, "Assertion.test_type", 8)); - tcpSamplerHashTree.appendChild(responseAssertion); - // 添加空的hashtree - tcpSamplerHashTree.appendChild(document.createElement(HASH_TREE_ELEMENT)); - - setupHashTree.appendChild(tcpSampler); - setupHashTree.appendChild(tcpSamplerHashTree); - - hashTree.appendChild(setupHashTree); - } - } - private Element createBoolProp(Document document, String name, boolean value) { Element boolProp = document.createElement("boolProp"); boolProp.setAttribute("name", name); From 2b9a239d6c4e25d9f2229770dabff4f5218aa528 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 24 Feb 2021 17:16:01 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=AF=BC=E5=87=BAjmx=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/service/APITestService.java | 9 +++++---- .../api/service/ApiAutomationService.java | 15 +++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 7e30d8b9c7..44504fbe8a 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -35,7 +35,6 @@ import org.aspectj.util.FileUtil; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; -import org.dom4j.QName; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -582,9 +581,11 @@ public class APITestService { for (Element itemElement : sampleProxyElementList) { if (isFromScenario) { testName = itemElement.attributeValue(attribute_testName); - String[] testNameArr = testName.split(scenarioCaseNameSplit); - if (testNameArr.length > 0) { - testName = testNameArr[0]; + if (StringUtils.isNotBlank(testName)) { + String[] testNameArr = testName.split(scenarioCaseNameSplit); + if (testNameArr.length > 0) { + testName = testNameArr[0]; + } } } itemElement.attribute(attribute_testName).setText(testName); 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 edbfe428a0..1328607458 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -457,12 +457,15 @@ public class ApiAutomationService { }); scenario.setHashTree(elements); } - if (StringUtils.isNotEmpty(element.getString("variables"))) { + if (element != null && StringUtils.isNotEmpty(element.getString("variables"))) { LinkedList variables = mapper.readValue(element.getString("variables"), new TypeReference>() { }); scenario.setVariables(variables); } + if (scenario == null) { + return null; + } // 针对导入的jmx 处理 if (CollectionUtils.isNotEmpty(scenario.getHashTree()) && (scenario.getHashTree().get(0) instanceof MsJmeterElement)) { scenario.toHashTree(jmeterHashTree, scenario.getHashTree(), config); @@ -879,9 +882,13 @@ public class ApiAutomationService { // 生成jmx List resList = new ArrayList<>(); apiScenarioWithBLOBs.forEach(item -> { - String jmx = generateJmx(item); - ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true)); - resList.add(scenrioExportJmx); + if (StringUtils.isNotEmpty(item.getScenarioDefinition())) { + String jmx = generateJmx(item); + if (StringUtils.isNotEmpty(jmx)) { + ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true)); + resList.add(scenrioExportJmx); + } + } }); return resList; } From 79780c8bacc595b624d3cc6ac9abe34efb5dc3a2 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 24 Feb 2021 18:12:20 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix(=E5=9C=BA=E6=99=AF=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=BC=95=E7=94=A8=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E8=AF=B7=E6=B1=82=E5=A4=B4=E6=9C=AA=E7=94=9F=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsScenario.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index c77efb653b..175345cb1b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -78,11 +78,28 @@ public class MsScenario extends MsTestElement { JSONObject element = JSON.parseObject(scenario.getScenarioDefinition()); hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference>() { }); + // 场景变量 + if (StringUtils.isNotEmpty(element.getString("variables"))) { + LinkedList variables = mapper.readValue(element.getString("variables"), + new TypeReference>() { + }); + this.setVariables(variables); + } + // 场景请求头 + if (StringUtils.isNotEmpty(element.getString("headers"))) { + LinkedList headers = mapper.readValue(element.getString("headers"), + new TypeReference>() { + }); + this.setHeaders(headers); + } + } + } catch (Exception ex) { ex.printStackTrace(); } } + // 设置共享cookie config.setEnableCookieShare(enableCookieShare); if (StringUtils.isNotEmpty(environmentId)) { ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class); From 10417ce6993d6b4ecd2f0a5ac699af95d603fcc0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 24 Feb 2021 18:29:42 +0800 Subject: [PATCH 7/7] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96):=20=E8=A7=84=E8=8C=83=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/dto/definition/request/MsTestElement.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 e287a189ed..cfcbe910bb 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 @@ -151,7 +151,7 @@ public abstract class MsTestElement { ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId()); + ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(element.getId()); if (apiDefinition != null) { element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() { }); @@ -159,6 +159,7 @@ public abstract class MsTestElement { } } catch (Exception ex) { ex.printStackTrace(); + LogUtil.error(ex.getMessage()); } }