0

If I pass the following args on a terminal window:

locust --headless --master --expect-workers 5 -H http://localhost -u 100 -r 30 -t 20s -T "Test" -L DEBUG 

Locust initializes as expected and I'm able to launch workers on another terminal window with locust --worker &. But if I create a locust.conf file, like following:

headless = true
master = true
expect-workers = 5
host = http://localhost
users = 100
spawn-rate = 30
run-time = 20s
tags = Test
loglevel = DEBUG

as we can see in Locust Documentation for configuration file, I can use just locust on terminal to start a Locust master instance. And as expected, Locust starts as master, waiting for workers to connect, but when trying to launch workers, they don't connect to master and exits with this message:

The Locust master port (5557) was busy. Close any applications using that port - perhaps an old
instance of Locust master is still running? (Socket bind failure: Address already in use)

Even when locust.conf file has a single master = true line, workers fail on connect to a locust master instance launched before. I understand that both ways of starting Locust as master is valid, but they behave differently, as they shouldn't.

Is there anything I didn't see that could provide a way to make Locust work with a config file, or that is the expected behavior?

Diego Bandeira
  • 101
  • 1
  • 6

2 Answers2

0

Once you've specified master in config, you can't override it with command line, so your processes all start as masters, even the ones you wanted to be workers.

This is a limitation in the underlying ConfigArgParse library that we use. In 1.4, I even added a separate --headful parameter to make it possible to override --headless, because it suffers from the same issue.

I guess we could make --slave automatically override --master, but that might also be a little confusing. The combination should at the very least give an error though.

My suggested workaround is to remove master from the config and only specify it on the command line. You can also specify additional config files using --config, if you want a file for all your master-only settings.

Cyberwiz
  • 11,027
  • 3
  • 20
  • 40
  • Then better not to have a `locust.conf` file, as either main and worker instances will load it, as you said, even if I pass `--config=nodes.conf` for workers instances. That way, I should have two config files, for example, `main.conf` and `nodes.conf`, and pass `--config` arg on command line for each one. right? – Diego Bandeira Nov 17 '20 at 21:35
  • Even better, just renaming `locust.conf` to `main.conf`, launch locust as master with `locust --config=main.conf` and launch worker instances with `locust --worker &`... That way worked as expected. – Diego Bandeira Nov 17 '20 at 21:47
0

I ended up with the following setup:

  • on main.conf file, removed host attribute and put it on User class;
  • Locust master instance launching with locust --config=main.conf
  • as many workers as needed to master instance start to distribute tests (5 in case): locust --worker &
Diego Bandeira
  • 101
  • 1
  • 6