fix(性能测试): 修复删除报告是多删除了测试相关文件的bug, 按照迭代次数执行只支持普通线程组

This commit is contained in:
Captain.B 2021-04-07 12:25:42 +08:00 committed by 刘瑞斌
parent 302d814a3c
commit 098eae1486
2 changed files with 27 additions and 35 deletions

View File

@ -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);
/*
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="登录" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
@ -711,7 +718,6 @@ public class JmeterDocumentParser implements DocumentParser {
</ThreadGroup>
*/
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);
// 选择按照迭代次数处理线程组

View File

@ -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<String> 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) {