refactor(性能测试): 避免重复添加 backend listener

--bug=1011512 --user=刘瑞斌 【性能测试】有一个性能测试一直在running,应是已经跑完了 https://www.tapd.cn/55049933/s/1124218
This commit is contained in:
CaptainB 2022-03-23 14:50:02 +08:00 committed by CountryBuilder
parent 26a7be69b7
commit d01b9b37be
2 changed files with 15 additions and 0 deletions

View File

@ -16,6 +16,7 @@ public class EngineContext {
private Map<String, Object> properties = new HashMap<>();
private Map<String, byte[]> testResourceFiles = new HashMap<>();
private Map<String, Boolean> splitFlag = new HashMap<>();
private boolean checkBackendListener;
public String getTestId() {
return testId;
@ -117,4 +118,12 @@ public class EngineContext {
public void setSplitFlag(Map<String, Boolean> splitFlag) {
this.splitFlag = splitFlag;
}
public boolean isCheckBackendListener() {
return checkBackendListener;
}
public void setCheckBackendListener(boolean checkBackendListener) {
this.checkBackendListener = checkBackendListener;
}
}

View File

@ -612,6 +612,10 @@ public class JmeterDocumentParser implements EngineSourceParser {
if (checkLicense() && !BooleanUtils.toBoolean(resourcePool.getBackendListener())) {
return;
}
// 已经添加过不再重复添加
if (context.isCheckBackendListener()) {
return;
}
Element listenerParent = getNextSibling(element);
@ -632,6 +636,8 @@ public class JmeterDocumentParser implements EngineSourceParser {
backendListener.addAttribute("enabled", "true");
listenerParent.addElement(HASH_TREE_ELEMENT);
// 标记已经添加上
context.setCheckBackendListener(true);
}
private boolean checkLicense() {