Skip to content

Commit fc94d5d

Browse files
Use clap derive, fixing behavior of --include flag. (#121)
* Add clap derive macros and attributes to structs * restore default behavior of stats_file * Use static Lazy for a Regex * Use Tmp struct for try config, needed for results_dir * comments * fix typo in comment * another typo * Direct port of tests from builder to derive version. Some tests now fail as a result of the new `-i` flag behavior. * Fix broken tests to use new `-i` behavior. * Add new test that uses built-in clap checker * Add new test. Verifies that the config file can come after an --include flag, and checks that a Ne filter can be properly parsed. * Remove old code, update use paths. * New test: checks that old `-i` behavior doesn't work * Improve consistency between output depicted in book and actual output. The text wrapping of the option descriptions depends on the size of the terminal window when the program is run. A wrapping length that is relatively short but leaves the descriptions in a fully separate column was chosen for the example in the book.
1 parent 34cf53b commit fc94d5d

File tree

5 files changed

+653
-678
lines changed

5 files changed

+653
-678
lines changed

Cargo.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ base64 = "0.21"
2323
body_reader = { path = "./lib/body_reader" }
2424
bytes = "1"
2525
channel = { path = "./lib/channel" }
26-
clap = { version = "4", features = ["cargo", "std", "help", "usage", "error-context", "wrap_help"], default-features = false }
26+
clap = { version = "4", features = ["derive", "cargo", "std", "help", "usage", "error-context", "wrap_help"], default-features = false }
2727
config = { path = "./lib/config" }
2828
csv = "1"
2929
ctrlc = "3"
@@ -39,6 +39,7 @@ hyper-tls = "0.5"
3939
itertools = "0.10"
4040
mod_interval = { path = "./lib/mod_interval" }
4141
native-tls = "0.2"
42+
once_cell = "1.17.1"
4243
rand = "0.8"
4344
regex = "1"
4445
select_any = { path = "./lib/select_any" }

guide/src/cli.md

+42-42
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ There are two ways that Pewpew can execute: either a full load test or a try run
44
<br/><br/>
55

66
```
7-
USAGE:
8-
pewpew <SUBCOMMAND>
7+
The HTTP load test tool https://familysearch.github.io/pewpew
98
10-
FLAGS:
11-
-h, --help Prints help information
12-
-V, --version Prints version information
9+
Usage: pewpew <COMMANND>
1310
14-
SUBCOMMANDS:
15-
run Runs a full load test
16-
try Runs the specified endpoint(s) a single time for testing purposes
11+
Commands:
12+
run Runs a full load test
13+
try Runs the specified endpoint(s) a single time for testing purposes
14+
help Print this message or the help of the given subcommand(s)
15+
16+
Options:
17+
-h, --help Prints help information
18+
-V, --version Prints version information
1719
```
1820

1921
As signified in the above help output, there are two subcommands `run` and `try`.
@@ -22,24 +24,22 @@ Here's the output of `pewpew run --help`:
2224
<br/><br/>
2325

2426
```
25-
USAGE:
26-
pewpew run <CONFIG>
27-
28-
OPTIONS:
29-
-h, --help Prints help information
30-
-f, --output-format <FORMAT> Formatting for stats printed to stdout [default: human] [possible values:
31-
human, json]
32-
-d, --results-directory <DIRECTORY> Directory to store results and logs
33-
-t, --start-at <START_AT> Specify the time the test should start at
34-
-o, --stats-file <STATS_FILE> Specify the filename for the stats file
35-
-s, --stats-file-format <FORMAT> Format for the stats file [default: json] [possible values: json]
36-
-w, --watch Watch the config file for changes and update the test accordingly
37-
38-
ARGS:
39-
<CONFIG> Load test config file to use
40-
41-
ARGS:
42-
<CONFIG> Load test config file to use
27+
Usage: pewpew run [OPTIONS] <CONFIG>
28+
29+
Arguments:
30+
<CONFIG> Load test config file to use
31+
32+
Options:
33+
-f, --output-format <FORMAT> Formatting for stats printed to stdout [default: human]
34+
[possible values: human, json]
35+
-d, --results-directory <DIRECTORY> Directory to store results and logs
36+
-t, --start-at <START_AT> Specify the time the test should start at
37+
-o, --stats-file <STATS_FILE> Specify the filename for the stats file
38+
-s, --stats-file-format <FORMAT> Format for the stats file [default: json] [possible values:
39+
json]
40+
-w, --watch Watch the config file for changes and update the test
41+
accordingly
42+
-h, --help Prints help information
4343
```
4444

4545
The `-f`, `--output-format` parameter allows changing the formatting of the stats which are printed to stdout.
@@ -54,22 +54,22 @@ Here's the output of `pewpew try --help`:
5454
<br/><br/>
5555

5656
```
57-
USAGE:
58-
pewpew try [OPTIONS] <CONFIG>
59-
60-
OPTIONS:
61-
-o, --file <FILE> Send results to the specified file instead of stdout
62-
-f, --format <FORMAT> Specify the format for the try run output [default: human] [possible values:
63-
human, json]
64-
-h, --help Prints help information
65-
-i, --include <INCLUDE>... Filter which endpoints are included in the try run. Filters work based on an
66-
endpoint's tags. Filters are specified in the format "key=value" where "*" is
67-
a wildcard. Any endpoint matching the filter is included in the test
68-
-l, --loggers Enable loggers defined in the config file
69-
-d, --results-directory <DIRECTORY> Directory to store logs (if enabled with --loggers)
70-
71-
ARGS:
72-
<CONFIG> Load test config file to use
57+
Usage: pewpew try [OPTIONS] <CONFIG>
58+
59+
Arguments:
60+
<CONFIG> Load test config file to use
61+
62+
Options:
63+
-o, --file <FILE> Send results to the specified file instead of stdout
64+
-f, --format <FORMAT> Specify the format for the try run output [default: human]
65+
[possible values: human, json]
66+
-i, --include <INCLUDE> Filter which endpoints are included in the try run. Filters
67+
work based on an endpoint's tags. Filters are specified in
68+
the format "key=value" where "*" is a wildcard. Any
69+
endpoint matching the filter is included in the test
70+
-l, --loggers Enable loggers defined in the config file
71+
-d, --results-directory <DIRECTORY> Directory to store logs (if enabled with --loggers)
72+
-h, --help Prints help information
7373
```
7474

7575
A try run will run one or more endpoints a single time and print out the raw HTTP requests and responses to stdout. By default all endpoints are included in the try run. This is useful for testing out a [config file](./config.md) before running a full load test. When the `--include` parameter is used, pewpew will automatically include any other endpoints needed to provide data for the explicitly included endpoints.

0 commit comments

Comments
 (0)