Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group related command line options together #1311

Merged
merged 9 commits into from
Apr 6, 2020
Merged

Group related command line options together #1311

merged 9 commits into from
Apr 6, 2020

Conversation

heyman
Copy link
Member

@heyman heyman commented Apr 5, 2020

This PR (for #1282) does the following

  • Group related command line options together using Argument Groups from argparse, resulting in a much better --help message
  • Removes deprecated --no-reset-stats options.

This PR is work in progress. Here's the current help output:

Usage: locust [OPTIONS] [LocustClass ...]

Common options:
  -h, --help            show this help message and exit
  -f LOCUSTFILE, --locustfile LOCUSTFILE
                        Python module file to import, e.g. '../other.py'. Default: locustfile
  -H HOST, --host HOST  Host to load test in the following format: http://10.21.32.33
  -c NUM_CLIENTS, --clients NUM_CLIENTS
                        Number of concurrent Locust users. Only used together with --headless
  -r HATCH_RATE, --hatch-rate HATCH_RATE
                        The rate per second in which clients are spawned. Only used together with --headless
  -t RUN_TIME, --run-time RUN_TIME
                        Stop after the specified amount of time, e.g. (300s, 20m, 3h, 1h30m, etc.). Only used together with --headless
  -l, --list            Show list of possible locust classes and exit

Web UI options:
  --web-host WEB_HOST   Host to bind the web interface to. Defaults to '' (all interfaces)
  --web-port WEB_PORT, -P WEB_PORT
                        Port on which to run web host
  --headless            Disable the web interface, and instead start the load test immediately. Requires -c and -t to be specified.

Master options:
  Options for running a Locust Master node when running Locust distributed. A Master node need Worker nodes that connect to it before it can run load tests.

  --master              Set locust to run in distributed mode with this process as master
  --master-bind-host MASTER_BIND_HOST
                        Interfaces (hostname, ip) that locust master should bind to. Only used when running with --master. Defaults to * (all available interfaces).
  --master-bind-port MASTER_BIND_PORT
                        Port that locust master should bind to. Only used when running with --master. Defaults to 5557.
  --expect-workers EXPECT_WORKERS
                        How many workers master should expect to connect before starting the test (only when --headless used).

Worker options:

  Options for running a Locust Worker node when running Locust distributed.
  Only the LOCUSTFILE (-f option) need to be specified when starting a Worker, since other options such as -c, -r, -t are specified on the Master node.

  --worker              Set locust to run in distributed mode with this process as worker
  --master-host MASTER_HOST
                        Host or IP address of locust master for distributed load testing. Only used when running with --worker. Defaults to 127.0.0.1.
  --master-port MASTER_PORT
                        The port to connect to that is used by the locust master for distributed load testing. Only used when running with --worker. Defaults to 5557.

Request statistics options:
  --csv CSVFILEBASE, --csv-base-name CSVFILEBASE
                        Store current request stats to files in CSV format.
  --csv-full-history    Store each stats entry in CSV format to _stats_history.csv file
  --print-stats         Print stats in the console
  --only-summary        Only print the summary stats
  --reset-stats         Reset statistics once hatching has been completed. Should be set on both master and workers when running in distributed mode

Logging options:
  --skip-log-setup      Disable Locust's logging setup. Instead, the configuration is provided by the Locust test or Python defaults.
  --loglevel LOGLEVEL, -L LOGLEVEL
                        Choose between DEBUG/INFO/WARNING/ERROR/CRITICAL. Default is INFO.
  --logfile LOGFILE     Path to log file. If not set, log will go to stdout/stderr

Step load options:
  --step-load           Enable Step Load mode to monitor how performance metrics varies when user load increases. Requires --step-clients and --step-time to be specified.
  --step-clients STEP_CLIENTS
                        Client count to increase by step in Step Load mode. Only used together with --step-load
  --step-time STEP_TIME
                        Step duration in Step Load mode, e.g. (300s, 20m, 3h, 1h30m, etc.). Only used together with --step-load

Other options:
  --show-task-ratio     Print table of the locust classes' task execution ratio
  --show-task-ratio-json
                        Print json data of the locust classes' task execution ratio
  --version, -V         Show program's version number and exit
  --exit-code-on-error EXIT_CODE_ON_ERROR
                        Sets the process exit code to use when a test result contain any failure or error
  -s STOP_TIMEOUT, --stop-timeout STOP_TIMEOUT
                        Number of seconds to wait for a simulated user to complete any executing task before exiting. Default is to terminate immediately. This parameter only needs to be specified for
                        the master process when running Locust distributed.

Locust user classes:
  LocustClass           Optionally specify which Locust classes that should be used (available Locust classes can be listed with -l or --list)

…m argparse.

Remove deprecated --no-reset-stats options.
@heyman heyman changed the title Group related command line options together using Argument Groups fro… Group related command line options together Apr 5, 2020
@heyman heyman linked an issue Apr 5, 2020 that may be closed by this pull request
2 tasks
@codecov
Copy link

codecov bot commented Apr 5, 2020

Codecov Report

Merging #1311 into master will increase coverage by 0.12%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1311      +/-   ##
==========================================
+ Coverage   80.36%   80.49%   +0.12%     
==========================================
  Files          23       23              
  Lines        2139     2148       +9     
  Branches      322      323       +1     
==========================================
+ Hits         1719     1729      +10     
+ Misses        342      340       -2     
- Partials       78       79       +1     
Impacted Files Coverage Δ
locust/contrib/fasthttp.py 89.83% <ø> (ø)
locust/stats.py 88.19% <ø> (ø)
locust/main.py 22.77% <28.57%> (-0.43%) ⬇️
locust/argument_parser.py 74.75% <100.00%> (+2.71%) ⬆️
locust/runners.py 76.65% <0.00%> (+0.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 461eafa...02701ad. Read the comment docs.

@cyberw
Copy link
Collaborator

cyberw commented Apr 6, 2020

Awesome! Dump the descriptions that just repeat the headers though (e.g "Logging options: Options related to logging")

@heyman heyman marked this pull request as ready for review April 6, 2020 08:50
@heyman
Copy link
Member Author

heyman commented Apr 6, 2020

Dump the descriptions that just repeat the headers though (e.g "Logging options: Options related to logging")

Done!

I've also renamed --no-web to --headless.

@cyberw
Copy link
Collaborator

cyberw commented Apr 6, 2020

"Enable Step Load mode to monitor how performance metrics varies when user load increases. Requires --step-clients and --step-time to be specified." This description is weird, sounds like it has something to do with monitoring...

@cyberw
Copy link
Collaborator

cyberw commented Apr 6, 2020

What is master_bind_port? It doesnt appear to be used anywhere (only master_port seems to actually be used)

@cyberw
Copy link
Collaborator

cyberw commented Apr 6, 2020

Oh, and we might want to change LocustClass to UserClass.

@cyberw
Copy link
Collaborator

cyberw commented Apr 6, 2020

We should probably add the output of locust --help to the docs somewhere (to help people who are googling/searching the docs). If that could be automated it would be really nice.

@heyman
Copy link
Member Author

heyman commented Apr 6, 2020

"Enable Step Load mode to monitor how performance metrics varies when user load increases. Requires --step-clients and --step-time to be specified." This description is weird, sounds like it has something to do with monitoring...

I agree. TBH, the "step load" implementation feels a bit half-baked to me, and I'm not very fond of it, but I think that should be a separate issue.

What is master_bind_port? It doesnt appear to be used anywhere (only master_port seems to actually be used)

It's the port that the master node listen to for incoming worker connections. It's used in main.py.

Oh, and we might want to change LocustClass to UserClass.

Yeah, I figured we could do that in the Locust -> User change.

We should probably add the output of locust --help to the docs somewhere (to help people who are googling/searching the docs). If that could be automated it would be really nice.

Great idea! I'll look into if we can get it into the documentation build flow.

@cyberw
Copy link
Collaborator

cyberw commented Apr 6, 2020

What is master_bind_port? It doesnt appear to be used anywhere (only master_port seems to actually be used)

It's the port that the master node listen to for incoming worker connections. It's used in main.py.

Ah, I tried searching for it in the project and was unable to find anyone reading the value, but I was accidentally searching for master_bind_port (space at the end). Sorry!

But it made me think: Perhaps splitting master settings and slave settings into their own groups would make it more clear?

Since we've added the abstract attribute to Locust, locust.main.is_locust no longer need the name of the item it's checking
@heyman
Copy link
Member Author

heyman commented Apr 6, 2020

But it made me think: Perhaps splitting master settings and slave settings into their own groups would make it more clear?

I tried it out and I think it's an improvement!

@heyman heyman merged commit aafab57 into master Apr 6, 2020
@heyman
Copy link
Member Author

heyman commented Apr 7, 2020

We should probably add the output of locust --help to the docs somewhere (to help people who are googling/searching the docs). If that could be automated it would be really nice.

Fixed in 51547a0. Here's how it looks in the docs: https://docs.locust.io/en/latest/quickstart.html#locust-command-line-interface

@heyman heyman deleted the cli-cleanup branch April 14, 2020 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up among the command line arguments
2 participants