Merge branch 'master' of https://github.com/metersphere/metersphere
# Conflicts: # backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java
This commit is contained in:
commit
adda8ff8a1
|
@ -393,7 +393,7 @@ public class APITestController {
|
||||||
String testName = runRequest.getName();
|
String testName = runRequest.getName();
|
||||||
|
|
||||||
//将jmx处理封装为通用方法
|
//将jmx处理封装为通用方法
|
||||||
jmxString = apiTestService.updateJmxString(jmxString,testName,true);
|
jmxString = apiTestService.updateJmxString(jmxString,testName,false);
|
||||||
|
|
||||||
JmxInfoDTO dto = new JmxInfoDTO();
|
JmxInfoDTO dto = new JmxInfoDTO();
|
||||||
dto.setName(runRequest.getName() + ".jmx");
|
dto.setName(runRequest.getName() + ".jmx");
|
||||||
|
|
|
@ -461,7 +461,20 @@ public class APITestService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public String updateJmxString(String jmxString,String testName,boolean updateHTTPSamplerProxyName) {
|
/**
|
||||||
|
* @param jmxString 原JMX文件
|
||||||
|
* @param testName 某些节点要替换的testName
|
||||||
|
* @param isFromScenario 是否来源于场景 (来源于场景的话,testName要进行处理)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String updateJmxString(String jmxString, String testName, boolean isFromScenario) {
|
||||||
|
if (isFromScenario) {
|
||||||
|
//如果调用源来自场景, 原testName是 案例<->场景 ,需要进行切分,只保留案例名
|
||||||
|
String[] testNameArr = testName.split("<->");
|
||||||
|
if (testNameArr.length > 0) {
|
||||||
|
testName = testNameArr[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
//将ThreadGroup的testname改为接口名称
|
//将ThreadGroup的testname改为接口名称
|
||||||
Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板
|
Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板
|
||||||
|
@ -473,12 +486,10 @@ public class APITestService {
|
||||||
|
|
||||||
List<Element> thirdHashTreeElementList = innerHashTreeElement.elements("hashTree");
|
List<Element> thirdHashTreeElementList = innerHashTreeElement.elements("hashTree");
|
||||||
for (Element element : thirdHashTreeElementList) {
|
for (Element element : thirdHashTreeElementList) {
|
||||||
if(updateHTTPSamplerProxyName){
|
|
||||||
List<Element> sampleProxyElementList = element.elements("HTTPSamplerProxy");
|
List<Element> sampleProxyElementList = element.elements("HTTPSamplerProxy");
|
||||||
for (Element itemElement : sampleProxyElementList) {
|
for (Element itemElement : sampleProxyElementList) {
|
||||||
itemElement.attribute("testname").setText(testName);
|
itemElement.attribute("testname").setText(testName);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//检查有没有自定义参数
|
//检查有没有自定义参数
|
||||||
List<Element> scriptHashTreeElementList = element.elements("hashTree");
|
List<Element> scriptHashTreeElementList = element.elements("hashTree");
|
||||||
for (Element scriptHashTreeElement : scriptHashTreeElementList) {
|
for (Element scriptHashTreeElement : scriptHashTreeElementList) {
|
||||||
|
|
|
@ -709,7 +709,7 @@ public class ApiAutomationService {
|
||||||
HashTree jmeterHashTree = generateHashTree(apiScenarios, request, null);
|
HashTree jmeterHashTree = generateHashTree(apiScenarios, request, null);
|
||||||
String jmx = testPlan.getJmx(jmeterHashTree);
|
String jmx = testPlan.getJmx(jmeterHashTree);
|
||||||
|
|
||||||
jmx = apiTestService.updateJmxString(jmx, testName, false);
|
jmx = apiTestService.updateJmxString(jmx,testName,true);
|
||||||
|
|
||||||
//将ThreadGroup的testname改为接口名称
|
//将ThreadGroup的testname改为接口名称
|
||||||
// Document doc = DocumentHelper.parseText(jmx);// 获取可续保保单列表报文模板
|
// Document doc = DocumentHelper.parseText(jmx);// 获取可续保保单列表报文模板
|
||||||
|
|
Loading…
Reference in New Issue