From 126b620fc7b1f804261c2c8dbceb3172cc8476ad Mon Sep 17 00:00:00 2001 From: CaptainB Date: Sun, 8 Oct 2023 11:19:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=8Ejmeter=E5=AF=BC=E5=85=A5=E8=BF=9B?= =?UTF-8?q?=E6=9D=A5=E7=9A=84jmx=E5=8C=85=E5=90=AB=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E7=9A=84ResultCollector=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=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=1031252 --user=刘瑞斌 【性能测试】github#26907,从JMeter界面导出JMX文件,再导入MeterSphere执行压测时,页面经常提示无法解析文件 https://www.tapd.cn/55049933/s/1423071 --- .../parse/xml/reader/JmeterDocumentParser.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/performance-test/backend/src/main/java/io/metersphere/parse/xml/reader/JmeterDocumentParser.java b/performance-test/backend/src/main/java/io/metersphere/parse/xml/reader/JmeterDocumentParser.java index 0eeb8dc7a9..605486ce49 100644 --- a/performance-test/backend/src/main/java/io/metersphere/parse/xml/reader/JmeterDocumentParser.java +++ b/performance-test/backend/src/main/java/io/metersphere/parse/xml/reader/JmeterDocumentParser.java @@ -29,6 +29,7 @@ public class JmeterDocumentParser implements EngineSourceParser { private final static String COLLECTION_PROP = "collectionProp"; private final static String CONCURRENCY_THREAD_GROUP = "com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup"; private final static String VARIABLE_THROUGHPUT_TIMER = "kg.apc.jmeter.timers.VariableThroughputTimer"; + private final static String RESULT_COLLECTOR = "ResultCollector"; private final static String THREAD_GROUP = "ThreadGroup"; private final static String POST_THREAD_GROUP = "PostThreadGroup"; private final static String SETUP_THREAD_GROUP = "SetupThreadGroup"; @@ -106,6 +107,9 @@ public class JmeterDocumentParser implements EngineSourceParser { processArgumentFiles(ele); } else if (nodeNameEquals(ele, KEYSTORE_CONFIG)) { processArgumentFiles(ele); + } else if (ele.getName().endsWith(RESULT_COLLECTOR)) { + // 处理结果收集器,性能测试不需要这些 + processResultCollector(ele); } } @@ -186,6 +190,13 @@ public class JmeterDocumentParser implements EngineSourceParser { } } + private void processResultCollector(Element element) { + Element hashTree = getNextSibling(element); + element.detach(); + hashTree.detach(); + } + + private void processArgumentFiles(Element element) { List childNodes = element.elements(); if (childNodes.size() == 0) {