简体   繁体   中英

Collect results from Distributed tests JMeter java code

I am trying to create Distributed tests using JMeter in java ( no GUI no command line )

In my code i use:

    List<String> addresses = Arrays.asList("address1","address2");
    HashTree tree = new HashTree();

    DistributedRunner dRunner = new DistributedRunner();

    dRunner.init(addresses,tree);
    dRunner.start();

The Server instances are already set up ( listening on address1 and so on ). However i cannot find an optimal way how to collect result from the server instances. Is there a way how to do so? Typically, master/slave have bidirectional communication, but this seems like the master sends command to execute test to slaves but slaves does not return result to master.

What is the correct way to achieve this?

Thanks!

What test plan you're running? Empty? If this is the case you should not get any results.

If there is some initialization code behind it you need to update your question with this code as it should be sufficient to define the .jtl result file and your master machine will collect the results from the slaves.

Example snippet, put it before dRunner.init(addresses,tree); line:

Summariser summer = null;
String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");
if (summariserName.length() > 0) {
    summer = new Summariser(summariserName);
}


String logFile = "/path/to/result.jtl";
ResultCollector logger = new ResultCollector(summer);
logger.setFilename(logFile);
tree.add(testPlanTree.getArray()[0], logger);

That would be the equivalent of providing the result file location via -t command-line argument otherwise the test will be started but the results will be going nowhere

More information and useful code snippets:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM