fix(性能测试): 修复从jmeter导入进来的jmx包含外部的ResultCollector不能正常使用的问题

--bug=1031252 --user=刘瑞斌 【性能测试】github#26907,从JMeter界面导出JMX文件,再导入MeterSphere执行压测时,页面经常提示无法解析文件 https://www.tapd.cn/55049933/s/1423071
This commit is contained in:
CaptainB 2023-10-08 11:19:56 +08:00 committed by 刘瑞斌
parent 0228b0e021
commit 126b620fc7
1 changed files with 11 additions and 0 deletions

View File

@ -29,6 +29,7 @@ public class JmeterDocumentParser implements EngineSourceParser {
private final static String COLLECTION_PROP = "collectionProp"; private final static String COLLECTION_PROP = "collectionProp";
private final static String CONCURRENCY_THREAD_GROUP = "com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup"; 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 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 THREAD_GROUP = "ThreadGroup";
private final static String POST_THREAD_GROUP = "PostThreadGroup"; private final static String POST_THREAD_GROUP = "PostThreadGroup";
private final static String SETUP_THREAD_GROUP = "SetupThreadGroup"; private final static String SETUP_THREAD_GROUP = "SetupThreadGroup";
@ -106,6 +107,9 @@ public class JmeterDocumentParser implements EngineSourceParser {
processArgumentFiles(ele); processArgumentFiles(ele);
} else if (nodeNameEquals(ele, KEYSTORE_CONFIG)) { } else if (nodeNameEquals(ele, KEYSTORE_CONFIG)) {
processArgumentFiles(ele); 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) { private void processArgumentFiles(Element element) {
List<Element> childNodes = element.elements(); List<Element> childNodes = element.elements();
if (childNodes.size() == 0) { if (childNodes.size() == 0) {