fix(接口测试): 修复jmx导入平台转成性能测试没有生成jmx的缺陷

--bug=1025157 --user=王孝刚 [性能测试]chrome插件录制的jmx导入接口自动化再转性能测试用例没有加载场景文件
https://www.tapd.cn/55049933/s/1359698
This commit is contained in:
wxg0103 2023-04-06 11:46:26 +08:00 committed by fit2-zhao
parent a1ef3f575b
commit ef1254c76d
1 changed files with 13 additions and 28 deletions

View File

@ -872,34 +872,19 @@ public class ApiScenarioService {
Map<String, String> envMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
scenario.setEnvironmentMap(envMap);
}
// 针对导入的jmx 处理
boolean isUseElement = false;
if (CollectionUtils.isNotEmpty(scenario.getHashTree())) {
for (MsTestElement testElement : scenario.getHashTree()) {
if (testElement instanceof MsJmeterElement) {
isUseElement = true;
}
}
}
if (isUseElement) {
scenario.toHashTree(jmeterHashTree, scenario.getHashTree(), config);
ElementUtil.accuracyHashTree(jmeterHashTree);
repositoryMetadata = ApiFileUtil.getRepositoryFileMetadata(jmeterHashTree);
jmx = scenario.getJmx(jmeterHashTree);
} else {
MsThreadGroup group = new MsThreadGroup();
group.setLabel(apiScenario.getName());
group.setName(apiScenario.getName());
group.setEnableCookieShare(scenario.isEnableCookieShare());
group.setOnSampleError(scenario.getOnSampleError());
group.setHashTree(new LinkedList<MsTestElement>() {{
this.add(scenario);
}});
testPlan.getHashTree().add(group);
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), config);
repositoryMetadata = ApiFileUtil.getRepositoryFileMetadata(jmeterHashTree);
jmx = testPlan.getJmx(jmeterHashTree);
}
MsThreadGroup group = new MsThreadGroup();
group.setLabel(apiScenario.getName());
group.setName(apiScenario.getName());
group.setEnableCookieShare(scenario.isEnableCookieShare());
group.setOnSampleError(scenario.getOnSampleError());
group.setHashTree(new LinkedList<MsTestElement>() {{
this.add(scenario);
}});
testPlan.getHashTree().add(group);
testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), config);
repositoryMetadata = ApiFileUtil.getRepositoryFileMetadata(jmeterHashTree);
jmx = testPlan.getJmx(jmeterHashTree);
} catch (Exception ex) {
LogUtil.error(ex);