Locust: Starting load test from the cli but monitoring from the web UI

Created on 30 Jun 2018  Â·  8Comments  Â·  Source: locustio/locust

I think this is a feature request. I'm expecting that I can use locust CLI to start the load test, but monitor the results from the web UI.

Description of issue / feature request

When I run locust --host=... -c 10 -r 5 it doesn't start anything. Because it starts the web UI, which presents the user a form to manually start the load test.

Expected behavior

I expect locust to start the test and let me monitor the results from the web UI.

Actual behavior

locust ignores the -c and -r when --no-web is specified.

Environment settings (for bug reports)

  • Locust version: 0.8.1
feature request wontfix

Most helpful comment

As a bit of a hack to gain a programmatic interface you could start locust with the web UI and then make a POST request to the /swarm endpoint with the hatch_rate and locust_count values.

E.g. curl -XPOST -d "hatch_rate=5&locust_count=100" http://my-locust-master-host/swarm

Then GET /stop when you're done.

All 8 comments

presents the user a form to manually start the load test.

I'm -1 on changing that functionality.

My use case is that I want to run a continuous load test in headless mode and monitor results without looking at process logs. This sounds quite reasonable to me.

Care to explain your -1?

@ahmetb
sorry for the hasty -1... I should clarify...

I thought that you were proposing to remove the setup screen where you define users and hatch rate and do everything via CLI... but now I understand your use case.

It's definitely a reasonable feature to invoke a test from the CLI while still allowing you to monitor via the web UI. However I don't want to replace the manual start we currently use... I'd want tboth ways of configuring a test to co-exist.

so to summarize this feauture..

  • If both -c and -r are specified, always launch the test immediately. When you visit the web UI, it should take you directly into the monitor screen and bypass the start screen. Does that sound right?

The only edge case I can think of is if -c or -r are specified, but not both.. and --no-web is not set.. In that case, we can't immediately start the test. So we could raise an error and exit with a message that this is an invalid configuration. Or we can delay starting until user starts the test manually from the setup screen.

Now the rub...

We lack development resources at the moment... I personally don't have time to devote to implementing this, but I will review a PR if you submit one (it should also include an update to the docs).

If both -c and -r are specified, always launch the test immediately. When you visit the web UI, it should take you directly into the monitor screen and bypass the start screen. Does that sound right?

Yes!

if -c or -r are specified, but not both

I think most load test software assumes hatch rate of "all at once" by default. So I think you can infer that you should start the test if both specified, without introducing any new flags.

I don't need this feature right now, just wanted to put it in the backlog to improve the project.

As a bit of a hack to gain a programmatic interface you could start locust with the web UI and then make a POST request to the /swarm endpoint with the hatch_rate and locust_count values.

E.g. curl -XPOST -d "hatch_rate=5&locust_count=100" http://my-locust-master-host/swarm

Then GET /stop when you're done.

@nealedj How do I pass run-time parameter through CURL -XPOST?
I mean How to say to the curl -XPOST that I want to run the locust test for specific duration.

@nityasantoshi,

that is not currently supported

While there is a possible use case for this, it is not very common, so I will close it (feel free to reopen if you absolutely want the feature and are willing to create a PR for it :)

There are other reporting solutions that work well with --no-web, like using https://github.com/SvenskaSpel/locust-plugins (Timescale + Grafana)

Was this page helpful?
0 / 5 - 0 ratings