fix(接口测试): 兼容导入的用例执行失败重跑无结果问题
This commit is contained in:
parent
8b97305b85
commit
5c72885c91
|
@ -130,7 +130,6 @@ public class ApiCaseSerialService {
|
||||||
envId = envMap.get(caseWithBLOBs.getProjectId());
|
envId = envMap.get(caseWithBLOBs.getProjectId());
|
||||||
}
|
}
|
||||||
if (caseWithBLOBs != null) {
|
if (caseWithBLOBs != null) {
|
||||||
String data = caseWithBLOBs.getRequest();
|
|
||||||
HashTree jmeterHashTree = new HashTree();
|
HashTree jmeterHashTree = new HashTree();
|
||||||
MsTestPlan testPlan = new MsTestPlan();
|
MsTestPlan testPlan = new MsTestPlan();
|
||||||
|
|
||||||
|
@ -152,6 +151,10 @@ public class ApiCaseSerialService {
|
||||||
}
|
}
|
||||||
group.setProjectId(caseWithBLOBs.getProjectId());
|
group.setProjectId(caseWithBLOBs.getProjectId());
|
||||||
MsTestElement testElement;
|
MsTestElement testElement;
|
||||||
|
// 数据兼容处理
|
||||||
|
JSONObject element = JSONUtil.parseObject(caseWithBLOBs.getRequest());
|
||||||
|
ElementUtil.dataFormatting(element);
|
||||||
|
String data = element.toString();
|
||||||
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) {
|
||||||
// 失败重试
|
// 失败重试
|
||||||
ApiRetryOnFailureService apiRetryOnFailureService = CommonBeanFactory.getBean(ApiRetryOnFailureService.class);
|
ApiRetryOnFailureService apiRetryOnFailureService = CommonBeanFactory.getBean(ApiRetryOnFailureService.class);
|
||||||
|
@ -159,9 +162,9 @@ public class ApiCaseSerialService {
|
||||||
data = StringUtils.isNotEmpty(retryData) ? retryData : data;
|
data = StringUtils.isNotEmpty(retryData) ? retryData : data;
|
||||||
// 格式化数据
|
// 格式化数据
|
||||||
testElement = apiRetryOnFailureService.retryParse(data);
|
testElement = apiRetryOnFailureService.retryParse(data);
|
||||||
MsTestElement element = parse(JSON.toJSONString(testElement.getHashTree().get(0)), testId, envId, caseWithBLOBs.getProjectId());
|
MsTestElement msTestElement = parse(JSON.toJSONString(testElement.getHashTree().get(0)), testId, envId, caseWithBLOBs.getProjectId());
|
||||||
testElement.setHashTree(new LinkedList<>() {{
|
testElement.setHashTree(new LinkedList<>() {{
|
||||||
this.add(element);
|
this.add(msTestElement);
|
||||||
}});
|
}});
|
||||||
} else {
|
} else {
|
||||||
testElement = parse(data, testId, envId, caseWithBLOBs.getProjectId());
|
testElement = parse(data, testId, envId, caseWithBLOBs.getProjectId());
|
||||||
|
@ -171,7 +174,6 @@ public class ApiCaseSerialService {
|
||||||
group.getHashTree().add(testElement);
|
group.getHashTree().add(testElement);
|
||||||
testPlan.getHashTree().add(group);
|
testPlan.getHashTree().add(group);
|
||||||
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig());
|
||||||
|
|
||||||
LoggerUtil.info("用例资源:" + caseWithBLOBs.getName() + ", 生成执行脚本JMX成功", runRequest.getReportId());
|
LoggerUtil.info("用例资源:" + caseWithBLOBs.getName() + ", 生成执行脚本JMX成功", runRequest.getReportId());
|
||||||
return jmeterHashTree;
|
return jmeterHashTree;
|
||||||
}
|
}
|
||||||
|
@ -189,8 +191,6 @@ public class ApiCaseSerialService {
|
||||||
private MsTestElement parse(String api, String planId, String envId, String projectId) {
|
private MsTestElement parse(String api, String planId, String envId, String projectId) {
|
||||||
try {
|
try {
|
||||||
JSONObject element = JSONUtil.parseObject(api);
|
JSONObject element = JSONUtil.parseObject(api);
|
||||||
ElementUtil.dataFormatting(element);
|
|
||||||
|
|
||||||
LinkedList<MsTestElement> list = new LinkedList<>();
|
LinkedList<MsTestElement> list = new LinkedList<>();
|
||||||
if (element != null && StringUtils.isNotEmpty(element.optString(ElementConstants.HASH_TREE))) {
|
if (element != null && StringUtils.isNotEmpty(element.optString(ElementConstants.HASH_TREE))) {
|
||||||
LinkedList<MsTestElement> elements = mapper.readValue(element.optString(ElementConstants.HASH_TREE),
|
LinkedList<MsTestElement> elements = mapper.readValue(element.optString(ElementConstants.HASH_TREE),
|
||||||
|
|
Loading…
Reference in New Issue