refactor(性能测试): 去掉teardown线程组,使用日志信息判断结束

This commit is contained in:
Captain.B 2021-02-23 19:02:09 +08:00
parent 396be1dd6b
commit dc0adf3d8b
1 changed files with 0 additions and 88 deletions

View File

@ -90,7 +90,6 @@ public class JmeterDocumentParser implements DocumentParser {
parseHashTree(ele); parseHashTree(ele);
} else if (nodeNameEquals(ele, TEST_PLAN)) { } else if (nodeNameEquals(ele, TEST_PLAN)) {
processSetupTestPlan(ele); processSetupTestPlan(ele);
processTearDownTestPlan(ele);
processCheckoutConfigTestElement(ele); processCheckoutConfigTestElement(ele);
processCheckoutDnsCacheManager(ele); processCheckoutDnsCacheManager(ele);
processCheckoutArguments(ele); processCheckoutArguments(ele);
@ -566,93 +565,6 @@ public class JmeterDocumentParser implements DocumentParser {
} }
} }
private void processTearDownTestPlan(Element ele) {
/*<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>*/
Document document = ele.getOwnerDocument();
Element tearDownSwitch = createBoolProp(document, "TestPlan.tearDown_on_shutdown", true);
ele.appendChild(tearDownSwitch);
Node hashTree = ele.getNextSibling();
while (!(hashTree instanceof Element)) {
hashTree = hashTree.getNextSibling();
}
/*
<PostThreadGroup guiclass="PostThreadGroupGui" testclass="PostThreadGroup" testname="tearDown Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</PostThreadGroup>
*/
Element tearDownElement = document.createElement("PostThreadGroup");
tearDownElement.setAttribute("guiclass", "PostThreadGroupGui");
tearDownElement.setAttribute("testclass", "PostThreadGroup");
tearDownElement.setAttribute("testname", "tearDown Thread Group");
tearDownElement.setAttribute("enabled", "true");
tearDownElement.appendChild(createStringProp(document, "ThreadGroup.on_sample_error", "continue"));
tearDownElement.appendChild(createStringProp(document, "ThreadGroup.num_threads", "1"));
tearDownElement.appendChild(createStringProp(document, "ThreadGroup.ramp_time", "1"));
tearDownElement.appendChild(createStringProp(document, "ThreadGroup.duration", ""));
tearDownElement.appendChild(createStringProp(document, "ThreadGroup.delay", ""));
tearDownElement.appendChild(createBoolProp(document, "ThreadGroup.scheduler", false));
tearDownElement.appendChild(createBoolProp(document, "ThreadGroup.same_user_on_next_iteration", true));
Element elementProp = document.createElement("elementProp");
elementProp.setAttribute("name", "ThreadGroup.main_controller");
elementProp.setAttribute("elementType", "LoopController");
elementProp.setAttribute("guiclass", "LoopControlPanel");
elementProp.setAttribute("testclass", "LoopController");
elementProp.setAttribute("testname", "Loop Controller");
elementProp.setAttribute("enabled", "true");
elementProp.appendChild(createBoolProp(document, "LoopController.continue_forever", false));
elementProp.appendChild(createStringProp(document, "LoopController.loops", "1"));
tearDownElement.appendChild(elementProp);
hashTree.appendChild(tearDownElement);
Element tearDownHashTree = document.createElement(HASH_TREE_ELEMENT);
/*
<OnceOnlyController guiclass="OnceOnlyControllerGui" testclass="OnceOnlyController" testname="Once Only Controller" enabled="true"/>
*/
Element onceOnlyController = document.createElement("OnceOnlyController");
onceOnlyController.setAttribute("guiclass", "OnceOnlyControllerGui");
onceOnlyController.setAttribute("testclass", "OnceOnlyController");
onceOnlyController.setAttribute("testname", "Once Only Controller");
onceOnlyController.setAttribute("enabled", "true");
tearDownHashTree.appendChild(onceOnlyController);
/*
<hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree/>
</hashTree>
*/
Element onceOnlyHashTree = document.createElement(HASH_TREE_ELEMENT);
Element debugSampler = document.createElement("DebugSampler");
debugSampler.setAttribute("guiclass", "TestBeanGUI");
debugSampler.setAttribute("testclass", "DebugSampler");
debugSampler.setAttribute("testname", "Debug Sampler");
debugSampler.setAttribute("enabled", "true");
debugSampler.appendChild(createBoolProp(document, "displayJMeterProperties", false));
debugSampler.appendChild(createBoolProp(document, "displayJMeterVariables", true));
debugSampler.appendChild(createBoolProp(document, "displaySystemProperties", false));
onceOnlyHashTree.appendChild(debugSampler);
// 添加空的 hashTree
onceOnlyHashTree.appendChild(document.createElement(HASH_TREE_ELEMENT));
tearDownHashTree.appendChild(onceOnlyHashTree);
hashTree.appendChild(tearDownHashTree);
// 添加backend listener
processCheckoutBackendListener(tearDownElement);
}
private Element createBoolProp(Document document, String name, boolean value) { private Element createBoolProp(Document document, String name, boolean value) {
Element tearDownSwitch = document.createElement("boolProp"); Element tearDownSwitch = document.createElement("boolProp");
tearDownSwitch.setAttribute("name", name); tearDownSwitch.setAttribute("name", name);