fix(接口定义): 修复接口定义带/导致转存性能测试失败的缺陷 (#17485)
--bug=1016355 --user=王孝刚 【接口测试】github#17452,接口自动化名字带 / ,转成性能测试保存会报错:文件上传失败 https://www.tapd.cn/55049933/s/1234397 Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
parent
58359cb409
commit
4c25c046a3
|
@ -301,53 +301,54 @@ public class EngineFactory {
|
|||
try {
|
||||
Element hashTree = null;
|
||||
Document rootDocument = null;
|
||||
for (FileMetadata fileMetadata : jmxFiles) {
|
||||
// 兼容处理
|
||||
byte[] bytes = fileMetadataService.loadFileAsBytes(fileMetadata.getId());
|
||||
InputStream inputSource = new ByteArrayInputStream(bytes);
|
||||
if (hashTree == null) {
|
||||
rootDocument = EngineSourceParserFactory.getDocument(inputSource);
|
||||
Element jmeterTestPlan = rootDocument.getRootElement();
|
||||
List<Element> childNodes = jmeterTestPlan.elements();
|
||||
if (CollectionUtils.isNotEmpty(jmxFiles)) {
|
||||
for (FileMetadata fileMetadata : jmxFiles) {
|
||||
// 兼容处理
|
||||
byte[] bytes = fileMetadataService.loadFileAsBytes(fileMetadata.getId());
|
||||
InputStream inputSource = new ByteArrayInputStream(bytes);
|
||||
if (hashTree == null) {
|
||||
rootDocument = EngineSourceParserFactory.getDocument(inputSource);
|
||||
Element jmeterTestPlan = rootDocument.getRootElement();
|
||||
List<Element> childNodes = jmeterTestPlan.elements();
|
||||
|
||||
outer:
|
||||
for (Element node : childNodes) {
|
||||
// jmeterTestPlan的子元素肯定是<hashTree></hashTree>
|
||||
List<Element> childNodes1 = node.elements();
|
||||
for (Element item : childNodes1) {
|
||||
if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) {
|
||||
hashTree = getNextSibling(item);
|
||||
break outer;
|
||||
outer:
|
||||
for (Element node : childNodes) {
|
||||
// jmeterTestPlan的子元素肯定是<hashTree></hashTree>
|
||||
List<Element> childNodes1 = node.elements();
|
||||
for (Element item : childNodes1) {
|
||||
if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) {
|
||||
hashTree = getNextSibling(item);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Document document = EngineSourceParserFactory.getDocument(inputSource);
|
||||
Element jmeterTestPlan = document.getRootElement();
|
||||
List<Element> childNodes = jmeterTestPlan.elements();
|
||||
for (Element node : childNodes) {
|
||||
// jmeterTestPlan的子元素肯定是<hashTree></hashTree>
|
||||
Element secondHashTree = node;
|
||||
List<Element> secondChildNodes = secondHashTree.elements();
|
||||
for (Element item : secondChildNodes) {
|
||||
if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) {
|
||||
secondHashTree = getNextSibling(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase("hashTree", secondHashTree.getName())) {
|
||||
List<Element> itemChildNodes = secondHashTree.elements();
|
||||
for (Element item1 : itemChildNodes) {
|
||||
hashTree.add((Element) item1.clone());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Document document = EngineSourceParserFactory.getDocument(inputSource);
|
||||
Element jmeterTestPlan = document.getRootElement();
|
||||
List<Element> childNodes = jmeterTestPlan.elements();
|
||||
for (Element node : childNodes) {
|
||||
// jmeterTestPlan的子元素肯定是<hashTree></hashTree>
|
||||
Element secondHashTree = node;
|
||||
List<Element> secondChildNodes = secondHashTree.elements();
|
||||
for (Element item : secondChildNodes) {
|
||||
if (StringUtils.equalsIgnoreCase("TestPlan", item.getName())) {
|
||||
secondHashTree = getNextSibling(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase("hashTree", secondHashTree.getName())) {
|
||||
List<Element> itemChildNodes = secondHashTree.elements();
|
||||
for (Element item1 : itemChildNodes) {
|
||||
hashTree.add((Element) item1.clone());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
inputSource.close();
|
||||
}
|
||||
//
|
||||
inputSource.close();
|
||||
return EngineSourceParserFactory.getBytes(rootDocument);
|
||||
}
|
||||
return EngineSourceParserFactory.getBytes(rootDocument);
|
||||
} catch (Exception e) {
|
||||
MSException.throwException(e);
|
||||
}
|
||||
|
|
|
@ -143,6 +143,9 @@ export default {
|
|||
let data = returnData.scenarioJmxList;
|
||||
data.forEach(d => {
|
||||
let jmxName = d.name + "_" + new Date().getTime() + ".jmx";
|
||||
if (jmxName.indexOf("/") !== -1) {
|
||||
jmxName = jmxName.replace(/\//g, "");
|
||||
}
|
||||
let threadGroups = findThreadGroup(d.jmx, jmxName);
|
||||
threadGroups.forEach(tg => {
|
||||
tg.options = {};
|
||||
|
|
Loading…
Reference in New Issue