Skip to content

Commit bf9e526

Browse files
committed
Update readme.md to reflect the changes made to the traffic generating scripts.
1 parent a1a4555 commit bf9e526

1 file changed

Lines changed: 40 additions & 21 deletions

File tree

readme.md

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,51 @@ Once you have an order displayed in HAL Explorer, you can submit payment:
3636

3737
Refer to the section `The Android client` below for more information.
3838

39-
**3. Use the provided bash script.**
39+
**3. Use the provided bash scripts.**
4040

41-
A bash script to generate traffic is provided.
42-
By default, the script will place a single order using the first available drink option and default location; pay with the built-in demo card (`1234123412341234`); and poll until a receipt link appears.
43-
Optionally, you can submit multiple and varied orders, force failures, and more.
41+
Two bash scripts are provided to generate traffic. Both require `curl` and `jq`.
4442

45-
Usage Examples:
46-
- Single, default order (orders first available drink using default location, pays with built-in demo card):
43+
**Single-run script: `scripts/generate-traffic.sh`**
44+
45+
By default it places a single order (first available drink, default location), pays with the built-in demo card (`1234123412341234`), and polls until a receipt link appears. You can run multiple or varied scenarios, force errors, add delays, and more.
46+
47+
Usage examples:
48+
- Single, default order:
4749
`./scripts/generate-traffic.sh`
48-
- All orders from file:
50+
- All scenarios from file (in order):
4951
`./scripts/generate-traffic.sh --scenarios scripts/order-scenarios.json`
50-
- Single order from file with override to force error:
52+
- One scenario by name with forced error:
5153
`./scripts/generate-traffic.sh --scenarios scripts/order-scenarios.json --scenario java_chip_takeaway --force-error INVALID_CARD`
52-
53-
Dependencies: `curl` and `jq`.
54-
55-
Optional flags:
56-
- `--force-error [INVALID_CARD|DOUBLE_PAY]`
57-
- INVALID_CARD: use an invalid card, expect HTTP 500.
58-
- DOUBLE_PAY: pay twice, second payment HTTP 404.
59-
- If the flag is provided with no value, defaults to INVALID_CARD.
60-
- `--scenarios <FILE>` load scenarios from a JSON file (e.g., `scripts/order-scenarios.json`).
61-
- With `--scenario <NAME>`: run only the specified scenario.
62-
- Without `--scenario`: execute all scenarios in the file, in order. In this mode, `--force-error` is ignored.
63-
- `--base-url <URL>` override the target base URL (default `http://localhost:8080`).
64-
- `--verbose` / `-v` for DEBUG-level payload dumps.
54+
- Cycle through all scenarios repeatedly (stop with Ctrl+C):
55+
`./scripts/generate-traffic.sh --scenarios scripts/order-scenarios.json --cycle`
56+
- One random scenario per run:
57+
`./scripts/generate-traffic.sh --scenarios scripts/order-scenarios.json --random-scenario`
58+
- Cycle with a new random scenario each time (0–3 s delay between runs by default):
59+
`./scripts/generate-traffic.sh --scenarios scripts/order-scenarios.json --random-scenario --cycle`
60+
- No delay between runs:
61+
`./scripts/generate-traffic.sh --scenarios scripts/order-scenarios.json --cycle --no-delay`
62+
63+
Options for `generate-traffic.sh`:
64+
- `--scenarios <FILE>` or `--scenarios=<FILE>` — JSON file of scenarios (e.g. `scripts/order-scenarios.json`). Without `--scenario`, runs all scenarios in order; with `--scenario <NAME>`, runs only that scenario.
65+
- `--scenario <NAME>` or `--scenario=<NAME>` — Run only the named scenario.
66+
- `--cycle` — With `--scenarios`: repeat indefinitely (Ctrl+C to stop). Without `--scenario` cycles through all; with `--scenario` repeats that scenario.
67+
- `--random-scenario` — With `--scenarios` and no `--scenario`: run one scenario chosen at random. With `--cycle`, pick a new random scenario each iteration.
68+
- `--delay-max <MS>` — Random delay 0..MS milliseconds between scenario runs (default 3000). Use `--no-delay` for no delay.
69+
- `--force-error [INVALID_CARD|DOUBLE_PAY]` — INVALID_CARD: invalid card, expect failure. DOUBLE_PAY: pay twice, second payment fails. Omitted value defaults to INVALID_CARD.
70+
- `--base-url <URL>` — Target base URL (default `http://localhost:8080`).
71+
- `--verbose` / `-v` — DEBUG-level payload dumps.
72+
73+
**Parallel users: `scripts/run-parallel-traffic.sh`**
74+
75+
Runs multiple “users” in parallel, each executing `generate-traffic.sh` with `--scenarios scripts/order-scenarios.json --random-scenario --cycle`. Output is prefixed with `[n]>` for user number `n`. A single Ctrl+C stops all users.
76+
77+
Usage (run from the `server` directory):
78+
- Default 5 parallel users:
79+
`./scripts/run-parallel-traffic.sh`
80+
- 10 parallel users:
81+
`./scripts/run-parallel-traffic.sh 10`
82+
- With verbose output per user:
83+
`./scripts/run-parallel-traffic.sh 3 --verbose`
6584

6685

6786
## IDE setup notes

0 commit comments

Comments
 (0)