Command Line Interface#
Basic Command#
Use the --help
or -h
argument to get help:
$ stressor --help
usage: stressor [-h] [-v | -q] [-n] [--no-color] [--log LOG_FILE] [-V]
{run,init} ...
Stress-test your web app.
positional arguments:
{run,init} sub-command help
run run a test suite scenario
init create new scenario folder and optinally convert HAR files
optional arguments:
-h, --help show this help message and exit
-v, --verbose increment verbosity by one (default: 3, range: 0..5)
-q, --quiet decrement verbosity by one
-n, --dry-run just simulate and log results, but don't change anything
--no-color prevent use of ansi terminal color codes
--log LOG_FILE Path to log file or folder (generate unique file name in the
latter case)
-V, --version display version info and exit (combine with -v for more
information)
See also https://github.com/mar10/stressor
$
run command#
The main purpose of the stressor command line tool is to execute a test scenario:
$ stressor run my_scenario_config.yaml --monitor
See also the help:
usage: stressor run [-h] [-v | -q] [-n] [--no-color] [--log LOG_FILE]
[-o OPTION] [--single] [--monitor]
[--max-errors MAX_ERRORS] [--max-time MAX_TIME]
SCENARIO
positional arguments:
SCENARIO path to configuration file or folder (default:
./scenario.yaml)
optional arguments:
-h, --help show this help message and exit
-v, --verbose increment verbosity by one (default: 3, range: 0..5)
-q, --quiet decrement verbosity by one
-n, --dry-run just simulate and log results, but don't change
anything
--no-color prevent use of ansi terminal color codes
--log LOG_FILE Path to log file or folder (generate unique file name
in the latter case)
-o OPTION, --option OPTION
override configuration, syntax `OPTION:VALUE`
(multiple values allowed)
--single Force `run_config.sessions.count: 1`, so only one
thread is run
--monitor Open a web server and browser application to display
real-time progress
--max-errors MAX_ERRORS
Stop after N errors (overrides `config.max_errors`)
--max-time MAX_TIME Stop after N seconds (overrides `config.max_time`)
$
init command#
Quickly create a folder with a scenario boilerplate:
$ stressor init ./scenario_1
or alternatively import an existing HAR file as a starting point:
$ stressor init ./scenario_1 --convert /path/to/output.har
See also the help:
$ stressor init --help
usage: stressor init [-h] [-v | -q] [-n] [--no-color] [--log LOG_FILE]
[--import HAR_FILE] [--force] [--opts OPTS]
TARGET
positional arguments:
TARGET target folder (created if not existing)
optional arguments:
-h, --help show this help message and exit
-v, --verbose increment verbosity by one (default: 3, range: 0..5)
-q, --quiet decrement verbosity by one
-n, --dry-run just simulate and log results, but don't change anything
--no-color prevent use of ansi terminal color codes
--log LOG_FILE Path to log file or folder (generate unique file name in
the latter case)
--import HAR_FILE optional HAR file that is converted
--force override existing files
--opts OPTS YAML file with conversion options
$
See the User Guide example for details.
Verbosity Level#
The verbosity level can have a value from 0 to 6:
Verbosity |
Option |
Log level |
Remarks |
---|---|---|---|
0 |
-qqq |
CRITICAL |
quiet |
1 |
ERROR |
||
2 |
-q |
WARN |
show less info |
3 |
INFO |
show write operations |
|
4 |
-v |
DEBUG |
show more info |
5 |
-vv |
DEBUG |
|
6 |
-vvv |
DEBUG |
Exit Codes#
The CLI returns those exit codes:
0: OK
1: Error (network, internal, ...)
2: CLI syntax error
3: Aborted by user
Logging#
By default, the library initializes and uses a python logger named ‘stressor’. This logger can be customized like so:
import logging
logger = logging.getLogger("stressor")
logger.setLevel(logging.DEBUG)