0

I am new to Locust and I am trying to programmatically incorporate the following CLI command into my script:

locust -f locustfile.py --host http://X.W.Z.Y:9999/ --headless -u 100 --run-time 1m --stop-timeout 99 --csv "some-timestamp" --csv-full-history --reset-stats --only-summary

Essentially running multiple local instances of locust in a headless fashion and storing the stats into csv file. I can programmatically start the locust instances and spawn the workers, but I have not been able to find the right documentation to understand how to deal with the storing of the stats into csv files.

Any help greatly appreciated!

user1024713
  • 31
  • 1
  • 2
  • How you were able to run locust instances and spawn the workers programmatically please explain and also did you able to store the stats into csv file (your actual issue) explain that as well? Thanks – Prashant Pathak Nov 01 '22 at 11:50

1 Answers1

0

Have you tried using the init_command_line_parser event hook or parsed_options attribute of the environment class at all?

https://docs.locust.io/en/stable/api.html#locust.event.Events.init_command_line_parser https://docs.locust.io/en/stable/api.html#locust.env.Environment.parsed_options

I am trying to do something similar I believe (programmatically set --csv option on environment to output stats to file) but am not having much luck. Have so far used argument_parser.parse_options to add the arguments but they don't seem to be acknowledged by the runner.

Also, small typo in your argument list -csv > --csv (in case not already noted).

Hopefully a further answer will help us both out on this!

Dave
  • 61
  • 4