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);