locustio / locust

Write scalable load tests in plain Python 🚗💨
MIT License
24.25k stars 2.93k forks source link

Specifying users in CLI should use a keyword parameter #2745

Open bakhtos opened 1 month ago

bakhtos commented 1 month ago

Prerequisites

Description

Currently, particular Users to run are specified on the command line like this

User classes:
  <UserClass1 UserClass2>
                        At the end of the command line, you can list User
                        classes to be used (available User classes can be
                        listed with --list). LOCUST_USER_CLASSES environment
                        variable can also be used to specify User classes.
                        Default is to use all available User classes

Doing this

at the end of the command line

as positional arguments is awkward if the command is big. The list of users should be a keyword CLI parameter like --users UserClass1 UserClass2, then it can be specified in any order of arguments in the command.

cyberw commented 1 month ago

I completely agree. If you can do it in a backwards-compatible way and update the docs I’m all for it.

If I could rewrite history, the positional parameter would be the locustfile (but I’m not sure its worth changing right now). If we were to do that we’d have to be careful though (bump major version, give good error messages, etc. And I guess that wasn’t your point anyway :)

bakhtos commented 1 month ago

@cyberw I believe it is possible to pickup the arguments both ways and then just merge the lists before passing it on. We can just leave the old way there but omit it from the documentation so that old scripts work but new users only learn the new way. I will work on this eventually. You can assign the issue to me