official locustio documentation tells about how to write simple locust tasks which run indefinitely.
Couldn't find out how to run load which lasts for a specific amount of time, so that the test will automatically stop after the specified interval.
I dont need it from the web interface, command line/code option will be just great.
I recently started using locust myself and unfortunately locust 0.7.1 does not provide a way to terminate a test based on a length of time.
It does however provide a way to terminate the test based on the number of requests that have been issued. If you run locust using the CLI interface you can specify that it stop execution after a specified number of requests have been handled. From the
locust --help
output:So, you can start a session with something along the lines of:
and once 500 requests have been handled it should terminate the test.
Pretty late to the party, but I stumbled upon this for stopping a test, it might be of help.
in your locust class.
Oh, and it accepts it's value in seconds.
Here my solution as per locust 0.8.1, we can't do define how long it will run in CLI mode
Time can be in minutes or second
locust now supports run-time parameter
--run-time=1h20m
. I installed locust from the master branch. (see GitHub issue). I think this feature is officially released in 0.9v.It's probably too late to answer, but might be helpful for someone in future. Locust now supports
-t
or--run-time
options to specify duration when running Locust with --no-web option. Fromlocust --help
:it's possible to stop an individual greenlet ("locust") by throwing a StopLocust exception, so you could add a guard in your Task that checks the time
this is undocumented behaviour, and may change in future, but it works in 0.7.2!
http://lookonmyworks.co.uk/2015/03/13/stopping-a-locust/