Merge branch 'v1.7'
This commit is contained in:
commit
9be6c192d0
|
@ -31,6 +31,7 @@ import io.metersphere.service.CheckPermissionService;
|
||||||
import io.metersphere.service.FileService;
|
import io.metersphere.service.FileService;
|
||||||
import io.metersphere.service.ScheduleService;
|
import io.metersphere.service.ScheduleService;
|
||||||
import io.metersphere.track.request.testplan.SaveTestPlanRequest;
|
import io.metersphere.track.request.testplan.SaveTestPlanRequest;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
|
@ -378,6 +379,7 @@ public class APITestController {
|
||||||
schedule.setEnable(request.isEnable());
|
schedule.setEnable(request.isEnable());
|
||||||
apiAutomationService.updateSchedule(schedule);
|
apiAutomationService.updateSchedule(schedule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/historicalDataUpgrade")
|
@PostMapping(value = "/historicalDataUpgrade")
|
||||||
public String historicalDataUpgrade(@RequestBody SaveHistoricalDataUpgrade request) {
|
public String historicalDataUpgrade(@RequestBody SaveHistoricalDataUpgrade request) {
|
||||||
return historicalDataUpgradeService.upgrade(request);
|
return historicalDataUpgradeService.upgrade(request);
|
||||||
|
@ -390,27 +392,8 @@ public class APITestController {
|
||||||
|
|
||||||
String testName = runRequest.getName();
|
String testName = runRequest.getName();
|
||||||
|
|
||||||
try{
|
//将jmx处理封装为通用方法
|
||||||
//将ThreadGroup的testname改为接口名称
|
jmxString = apiTestService.updateJmxString(jmxString,testName,true);
|
||||||
Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板
|
|
||||||
Element root = doc.getRootElement();
|
|
||||||
Element rootHashTreeElement = root.element("hashTree");
|
|
||||||
Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0);
|
|
||||||
Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0);
|
|
||||||
theadGroupElement.attribute("testname").setText(testName);
|
|
||||||
|
|
||||||
List<Element> thirdHashTreeElementList =innerHashTreeElement.elements("hashTree");
|
|
||||||
for (Element element:thirdHashTreeElementList) {
|
|
||||||
List<Element> sampleProxyElementList = element.elements("HTTPSamplerProxy");
|
|
||||||
for (Element itemElement: sampleProxyElementList) {
|
|
||||||
itemElement.attribute("testname").setText(testName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jmxString = root.asXML();
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
JmxInfoDTO dto = new JmxInfoDTO();
|
JmxInfoDTO dto = new JmxInfoDTO();
|
||||||
dto.setName(runRequest.getName() + ".jmx");
|
dto.setName(runRequest.getName() + ".jmx");
|
||||||
|
|
|
@ -32,6 +32,9 @@ import io.metersphere.track.service.TestCaseService;
|
||||||
import org.apache.dubbo.common.URL;
|
import org.apache.dubbo.common.URL;
|
||||||
import org.apache.dubbo.common.constants.CommonConstants;
|
import org.apache.dubbo.common.constants.CommonConstants;
|
||||||
import org.aspectj.util.FileUtil;
|
import org.aspectj.util.FileUtil;
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.DocumentHelper;
|
||||||
|
import org.dom4j.Element;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
@ -457,4 +460,63 @@ public class APITestService {
|
||||||
copyBodyFiles(test.getId(), sourceId);
|
copyBodyFiles(test.getId(), sourceId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String updateJmxString(String jmxString,String testName,boolean updateHTTPSamplerProxyName) {
|
||||||
|
try {
|
||||||
|
//将ThreadGroup的testname改为接口名称
|
||||||
|
Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板
|
||||||
|
Element root = doc.getRootElement();
|
||||||
|
Element rootHashTreeElement = root.element("hashTree");
|
||||||
|
Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0);
|
||||||
|
Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0);
|
||||||
|
theadGroupElement.attribute("testname").setText(testName);
|
||||||
|
|
||||||
|
List<Element> thirdHashTreeElementList = innerHashTreeElement.elements("hashTree");
|
||||||
|
for (Element element : thirdHashTreeElementList) {
|
||||||
|
if(updateHTTPSamplerProxyName){
|
||||||
|
List<Element> sampleProxyElementList = element.elements("HTTPSamplerProxy");
|
||||||
|
for (Element itemElement : sampleProxyElementList) {
|
||||||
|
itemElement.attribute("testname").setText(testName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//检查有没有自定义参数
|
||||||
|
List<Element> scriptHashTreeElementList = element.elements("hashTree");
|
||||||
|
for (Element scriptHashTreeElement : scriptHashTreeElementList) {
|
||||||
|
boolean isRemove = false;
|
||||||
|
List<Element> removeElement = new ArrayList<>();
|
||||||
|
List<Element> scriptElementItemList = scriptHashTreeElement.elements();
|
||||||
|
for (Element hashTreeItemElement : scriptElementItemList) {
|
||||||
|
String className = hashTreeItemElement.attributeValue("testclass");
|
||||||
|
String qname = hashTreeItemElement.getQName().getName();
|
||||||
|
|
||||||
|
if (isRemove) {
|
||||||
|
if (org.apache.commons.lang3.StringUtils.equals("hashTree", qname)) {
|
||||||
|
removeElement.add(hashTreeItemElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isRemove = false;
|
||||||
|
if (org.apache.commons.lang3.StringUtils.equals(className, "JSR223PostProcessor")) {
|
||||||
|
List<Element> scriptElements = hashTreeItemElement.elements("stringProp");
|
||||||
|
for (Element scriptElement : scriptElements) {
|
||||||
|
String scriptName = scriptElement.attributeValue("name");
|
||||||
|
String contentValue = scriptElement.getStringValue();
|
||||||
|
|
||||||
|
if ("script".equals(scriptName) && contentValue.startsWith("io.metersphere.api.jmeter.JMeterVars.addVars")) {
|
||||||
|
isRemove = true;
|
||||||
|
removeElement.add(hashTreeItemElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Element itemElement : removeElement) {
|
||||||
|
scriptHashTreeElement.remove(itemElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jmxString = root.asXML();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return jmxString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@ public class ApiAutomationService {
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioMapper apiScenarioMapper;
|
private ApiScenarioMapper apiScenarioMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
private APITestService apiTestService;
|
||||||
|
@Resource
|
||||||
private ExtApiScenarioMapper extApiScenarioMapper;
|
private ExtApiScenarioMapper extApiScenarioMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||||
|
@ -667,14 +669,17 @@ 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);
|
||||||
|
|
||||||
//将ThreadGroup的testname改为接口名称
|
//将ThreadGroup的testname改为接口名称
|
||||||
Document doc = DocumentHelper.parseText(jmx);// 获取可续保保单列表报文模板
|
// Document doc = DocumentHelper.parseText(jmx);// 获取可续保保单列表报文模板
|
||||||
Element root = doc.getRootElement();
|
// Element root = doc.getRootElement();
|
||||||
Element rootHashTreeElement = root.element("hashTree");
|
// Element rootHashTreeElement = root.element("hashTree");
|
||||||
Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0);
|
// Element innerHashTreeElement = rootHashTreeElement.elements("hashTree").get(0);
|
||||||
Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0);
|
// Element theadGroupElement = innerHashTreeElement.elements("ThreadGroup").get(0);
|
||||||
theadGroupElement.attribute("testname").setText(testName);
|
// theadGroupElement.attribute("testname").setText(testName);
|
||||||
jmx = root.asXML();
|
// jmx = root.asXML();
|
||||||
|
|
||||||
String name = request.getName() + ".jmx";
|
String name = request.getName() + ".jmx";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE schedule
|
||||||
|
MODIFY COLUMN `key` VARCHAR(255);
|
Loading…
Reference in New Issue