use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class RemoteStart method getTestTree.
private HashTree getTestTree() {
GuiPackage gui = GuiPackage.getInstance();
HashTree testTree = gui.getTreeModel().getTestPlan();
JMeter.convertSubTree(testTree);
testTree.add(testTree.getArray()[0], gui.getMainFrame());
// Used for remote notification of threads start/stop,see BUG 54152
testTree.add(testTree.getArray()[0], new RemoteThreadsListenerTestElement());
return testTree;
}
use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class DistributedRunnerTest method testSuccess.
@Test
public void testSuccess() throws Exception {
createJmeterEnv();
JMeterUtils.setProperty(DistributedRunner.RETRIES_NUMBER, "1");
JMeterUtils.setProperty(DistributedRunner.CONTINUE_ON_FAIL, "false");
DistributedRunnerEmul obj = new DistributedRunnerEmul();
obj.engines.add(new EmulatorEngine());
obj.engines.add(new EmulatorEngine());
List<String> hosts = Arrays.asList("test1", "test2");
obj.init(hosts, new HashTree());
obj.start();
obj.shutdown(hosts);
obj.stop(hosts);
obj.exit(hosts);
}
use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class ClientJMeterEngine method runTest.
@Override
public void runTest() throws JMeterEngineException {
log.info("running clientengine run method");
// See https://bz.apache.org/bugzilla/show_bug.cgi?id=55510
JMeterContextService.clearTotalThreads();
HashTree testTree = test;
synchronized (testTree) {
// limit the changes to client only test elements
testTree.traverse(new PreCompiler(true));
testTree.traverse(new TurnElementsOn());
testTree.traverse(new ConvertListeners());
}
String methodName = "unknown";
try {
JMeterContextService.startTest();
/*
* Add fix for Deadlocks, see:
*
* See https://bz.apache.org/bugzilla/show_bug.cgi?id=48350
*/
File baseDirRelative = FileServer.getFileServer().getBaseDirRelative();
String scriptName = FileServer.getFileServer().getScriptName();
synchronized (LOCK) {
// NOSONAR Used for tracing
methodName = "rconfigure()";
remote.rconfigure(testTree, host, baseDirRelative, scriptName);
}
// $NON-NLS-1$
log.info("sent test to " + host + " basedir='" + baseDirRelative + "'");
if (savep == null) {
savep = new Properties();
}
log.info("Sending properties " + savep);
try {
// NOSONAR Used for tracing
methodName = "rsetProperties()";
remote.rsetProperties(savep);
} catch (RemoteException e) {
log.warn("Could not set properties: " + e.toString());
}
methodName = "rrunTest()";
remote.rrunTest();
log.info("sent run command to " + host);
} catch (IllegalStateException ex) {
// $NON-NLS-1$ $NON-NLS-2$
log.error("Error in " + methodName + " method " + ex);
tidyRMI(log);
// Don't wrap this error - display it as is
throw ex;
} catch (Exception ex) {
// $NON-NLS-1$ $NON-NLS-2$
log.error("Error in " + methodName + " method " + ex);
tidyRMI(log);
// $NON-NLS-1$ $NON-NLS-2$
throw new JMeterEngineException("Error in " + methodName + " method " + ex, ex);
}
}
use of org.apache.jorphan.collections.HashTree in project jmeter by apache.
the class JMeter method convertSubTree.
/**
* Remove disabled elements
* Replace the ReplaceableController with the target subtree
*
* @param tree The {@link HashTree} to convert
*/
public static void convertSubTree(HashTree tree) {
LinkedList<Object> copyList = new LinkedList<>(tree.list());
for (Object o : copyList) {
if (o instanceof TestElement) {
TestElement item = (TestElement) o;
if (item.isEnabled()) {
if (item instanceof ReplaceableController) {
ReplaceableController rc = ensureReplaceableControllerIsLoaded(item);
HashTree subTree = tree.getTree(item);
if (subTree != null) {
HashTree replacementTree = rc.getReplacementSubTree();
if (replacementTree != null) {
convertSubTree(replacementTree);
tree.replaceKey(item, rc);
tree.set(rc, replacementTree);
}
}
} else {
// not Replaceable Controller
convertSubTree(tree.getTree(item));
}
} else {
// Not enabled
tree.remove(item);
}
} else {
// Not a TestElement
JMeterTreeNode item = (JMeterTreeNode) o;
if (item.isEnabled()) {
// @see StandardJMeterEngine.run()
if (item.getUserObject() instanceof ReplaceableController) {
TestElement controllerAsItem = item.getTestElement();
ReplaceableController rc = ensureReplaceableControllerIsLoaded(controllerAsItem);
HashTree subTree = tree.getTree(item);
if (subTree != null) {
HashTree replacementTree = rc.getReplacementSubTree();
if (replacementTree != null) {
convertSubTree(replacementTree);
tree.replaceKey(item, rc);
tree.set(rc, replacementTree);
}
}
} else {
// Not a ReplaceableController
convertSubTree(tree.getTree(item));
TestElement testElement = item.getTestElement();
tree.replaceKey(item, testElement);
}
} else {
// Not enabled
tree.remove(item);
}
}
}
}
Aggregations