From 098eae148695c905586127ba7e786858b0704464 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Wed, 7 Apr 2021 12:25:42 +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=E5=88=A0=E9=99=A4=E6=8A=A5=E5=91=8A=E6=98=AF?= =?UTF-8?q?=E5=A4=9A=E5=88=A0=E9=99=A4=E4=BA=86=E6=B5=8B=E8=AF=95=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=87=E4=BB=B6=E7=9A=84bug,=20=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E8=BF=AD=E4=BB=A3=E6=AC=A1=E6=95=B0=E6=89=A7=E8=A1=8C=E5=8F=AA?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=99=AE=E9=80=9A=E7=BA=BF=E7=A8=8B=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xml/reader/jmx/JmeterDocumentParser.java | 44 +++++++++++-------- .../io/metersphere/service/FileService.java | 18 +------- 2 files changed, 27 insertions(+), 35 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 34a683f4b0..52f204b3aa 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 @@ -100,26 +100,13 @@ public class JmeterDocumentParser implements DocumentParser { processCheckoutBackendListener(ele); processCheckoutAutoStopListener(ele); } else if (nodeNameEquals(ele, CONCURRENCY_THREAD_GROUP)) { - processThreadGroup(ele); + processThreadType(ele); processThreadGroupName(ele); processCheckoutTimer(ele); } else if (nodeNameEquals(ele, VARIABLE_THROUGHPUT_TIMER)) { processVariableThroughputTimer(ele); } else if (nodeNameEquals(ele, THREAD_GROUP)) { - Object threadType = context.getProperty("threadType"); - if (threadType instanceof List) { - Object o = ((List) threadType).get(0); - ((List) threadType).remove(0); - if ("DURATION".equals(o)) { - processThreadGroup(ele); - } - if ("ITERATION".equals(o)) { - processIterationThreadGroup(ele); - } - } else { - processThreadGroup(ele); - } - + processThreadType(ele); processThreadGroupName(ele); processCheckoutTimer(ele); } else if (nodeNameEquals(ele, BACKEND_LISTENER)) { @@ -147,6 +134,22 @@ public class JmeterDocumentParser implements DocumentParser { } } + private void processThreadType(Element ele) { + Object threadType = context.getProperty("threadType"); + if (threadType instanceof List) { + Object o = ((List) threadType).get(0); + ((List) threadType).remove(0); + if ("DURATION".equals(o)) { + processThreadGroup(ele); + } + if ("ITERATION".equals(o)) { + processIterationThreadGroup(ele); + } + } else { + processThreadGroup(ele); + } + } + private void processAutoStopListener(Element autoStopListener) { Object autoStopDelays = context.getProperty("autoStopDelay"); String autoStopDelay = "30"; @@ -695,6 +698,10 @@ public class JmeterDocumentParser implements DocumentParser { } private void processBaseThreadGroup(Element threadGroup) { + Document document = threadGroup.getOwnerDocument(); + document.renameNode(threadGroup, threadGroup.getNamespaceURI(), THREAD_GROUP); + threadGroup.setAttribute("guiclass", THREAD_GROUP + "Gui"); + threadGroup.setAttribute("testclass", THREAD_GROUP); /* continue @@ -711,7 +718,6 @@ public class JmeterDocumentParser implements DocumentParser { */ removeChildren(threadGroup); - Document document = threadGroup.getOwnerDocument(); Object targetLevels = context.getProperty("TargetLevel"); String threads = "10"; if (targetLevels instanceof List) { @@ -893,6 +899,10 @@ public class JmeterDocumentParser implements DocumentParser { } private void processIterationThreadGroup(Element threadGroup) { + Document document = threadGroup.getOwnerDocument(); + document.renameNode(threadGroup, threadGroup.getNamespaceURI(), THREAD_GROUP); + threadGroup.setAttribute("guiclass", THREAD_GROUP + "Gui"); + threadGroup.setAttribute("testclass", THREAD_GROUP); // 检查 threadgroup 后面的hashtree是否为空 Node hashTree = threadGroup.getNextSibling(); while (!(hashTree instanceof Element)) { @@ -901,8 +911,6 @@ public class JmeterDocumentParser implements DocumentParser { if (!hashTree.hasChildNodes()) { MSException.throwException(Translator.get("jmx_content_valid")); } - // 重命名 tagName - Document document = threadGroup.getOwnerDocument(); removeChildren(threadGroup); // 选择按照迭代次数处理线程组 diff --git a/backend/src/main/java/io/metersphere/service/FileService.java b/backend/src/main/java/io/metersphere/service/FileService.java index 74c095bc0f..b0f574b6be 100644 --- a/backend/src/main/java/io/metersphere/service/FileService.java +++ b/backend/src/main/java/io/metersphere/service/FileService.java @@ -3,7 +3,6 @@ package io.metersphere.service; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.FileContentMapper; import io.metersphere.base.mapper.FileMetadataMapper; -import io.metersphere.base.mapper.LoadTestFileMapper; import io.metersphere.base.mapper.TestCaseFileMapper; import io.metersphere.commons.constants.FileType; import io.metersphere.commons.exception.MSException; @@ -27,8 +26,6 @@ public class FileService { @Resource private FileMetadataMapper fileMetadataMapper; @Resource - private LoadTestFileMapper loadTestFileMapper; - @Resource private FileContentMapper fileContentMapper; @Resource private TestCaseFileMapper testCaseFileMapper; @@ -61,23 +58,10 @@ public class FileService { FileContentExample example2 = new FileContentExample(); example2.createCriteria().andFileIdIn(ids); fileContentMapper.deleteByExample(example2); - - LoadTestFileExample example3 = new LoadTestFileExample(); - example3.createCriteria().andFileIdIn(ids); - loadTestFileMapper.deleteByExample(example3); } public void deleteFileRelatedByIds(List ids) { - if (CollectionUtils.isEmpty(ids)) { - return; - } - FileMetadataExample example = new FileMetadataExample(); - example.createCriteria().andIdIn(ids); - fileMetadataMapper.deleteByExample(example); - - FileContentExample example2 = new FileContentExample(); - example2.createCriteria().andFileIdIn(ids); - fileContentMapper.deleteByExample(example2); + deleteFileByIds(ids); } public FileMetadata saveFile(MultipartFile file, String projectId, String fileId) {