redfireforge-cli 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +237 -0
- package/dist/redfireforge.mjs +68784 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# RedfireForge CLI
|
|
2
|
+
|
|
3
|
+
> API Performance Testing from the Command Line
|
|
4
|
+
|
|
5
|
+
Run API performance tests and workflows using YAML or JSON test files. The CLI uses the same execution engine as the RedfireForge desktop application, ensuring consistent behavior between GUI and command-line testing.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Option 1: npm Package (Recommended)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g redfireforge-cli
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This installs two equivalent commands: `redfireforge` (full name) and **`rff`** (short alias — same binary, just less to type). `rff` is never claimed by the desktop app installer, so it's always unambiguous even on a machine that also has the desktop app installed.
|
|
16
|
+
|
|
17
|
+
### Option 2: Desktop App CLI Mode
|
|
18
|
+
|
|
19
|
+
If you have the RedfireForge desktop app installed, use the `--cli` flag:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# macOS/Linux (symlink created during installation)
|
|
23
|
+
redfireforge --cli run tests/test.yaml
|
|
24
|
+
|
|
25
|
+
# Windows (added to PATH during installation)
|
|
26
|
+
redfireforge --cli run tests/test.yaml
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> **Note:** the desktop app's own `redfireforge` command launches the GUI by default (`--cli` switches it to CLI mode) — this is a *different* binary than Option 1's npm package, even though they share the same name. If you have both installed, prefer `rff` (Option 1) or `redfireforge --cli` (Option 2) explicitly rather than relying on bare `redfireforge`, since whichever one wins your `$PATH` determines which behavior you get.
|
|
30
|
+
|
|
31
|
+
### Option 3: From Source
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/your-org/redfireforge.git
|
|
35
|
+
cd redfireforge
|
|
36
|
+
npm install
|
|
37
|
+
npx tsx cli/index.ts run tests/test.yaml
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Validate a test file
|
|
44
|
+
redfireforge validate tests/api-test.yaml
|
|
45
|
+
|
|
46
|
+
# Run a simple test
|
|
47
|
+
redfireforge run tests/api-test.yaml
|
|
48
|
+
|
|
49
|
+
# Run with concurrency and iterations
|
|
50
|
+
redfireforge run tests/api-test.yaml -c 10 -i 100
|
|
51
|
+
|
|
52
|
+
# Run a workflow performance test
|
|
53
|
+
redfireforge workflow tests/checkout-flow.yaml -i 50 -c 5
|
|
54
|
+
|
|
55
|
+
# Every command above also works with the short "rff" alias:
|
|
56
|
+
rff run tests/api-test.yaml -c 10 -i 100
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Commands
|
|
60
|
+
|
|
61
|
+
| Command | Description |
|
|
62
|
+
|---------|-------------|
|
|
63
|
+
| `run <file>` | Execute a test file |
|
|
64
|
+
| `workflow <file>` | Execute a workflow as a performance test |
|
|
65
|
+
| `validate <file>` | Validate a test file without running |
|
|
66
|
+
| `validate-workflow <file>` | Validate a workflow file without running |
|
|
67
|
+
| `mock simulate <file>` | Run saved API Mock samples (side-effect-free) |
|
|
68
|
+
| `mock verify <file>` | Assert live journal calls (or `--simulate` for offline corpus) |
|
|
69
|
+
| `mock start <file>` | Start mock listeners (companion, or in-process `--standalone`) |
|
|
70
|
+
|
|
71
|
+
### API Mock Studio (`mock`)
|
|
72
|
+
|
|
73
|
+
Headless helpers for API Mock Studio definitions (native JSON/YAML export envelopes or workspace files).
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Simulate samples against a definition (same engine as GUI)
|
|
77
|
+
npx tsx cli/index.ts mock simulate ./api-mock-workspace.json -o results.json --junit junit.xml
|
|
78
|
+
|
|
79
|
+
# Verify live journal (requires companion + running mock)
|
|
80
|
+
npx tsx cli/index.ts mock verify ./api-mock-workspace.json --expect-outcome matched --min-calls 1
|
|
81
|
+
|
|
82
|
+
# Offline corpus (same engine as GUI Simulate)
|
|
83
|
+
npx tsx cli/index.ts mock verify ./api-mock-workspace.json --simulate --expect-outcome matched --min-calls 1
|
|
84
|
+
|
|
85
|
+
# Start listeners. Companion on :3001 is preferred; falls back to in-process.
|
|
86
|
+
npx tsx cli/index.ts mock start ./api-mock-workspace.json --port 4600 --wait-ready
|
|
87
|
+
|
|
88
|
+
# Force in-process listeners (no companion) — useful in Docker/CI
|
|
89
|
+
npx tsx cli/index.ts mock start ./api-mock-workspace.json --standalone --wait-ready
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
| Option | Commands | Description |
|
|
93
|
+
|--------|----------|-------------|
|
|
94
|
+
| `--server <id>` | simulate, verify | Target server (default: active / first) |
|
|
95
|
+
| `-o, --output <path>` | simulate | Write JSON results |
|
|
96
|
+
| `--junit <path>` | simulate | Write JUnit XML |
|
|
97
|
+
| `--min-calls <n>` | verify | Require at least N matching journal calls (samples when `--simulate`) |
|
|
98
|
+
| `--expect-outcome <outcome>` | verify | Require matching outcome |
|
|
99
|
+
| `--route <id>` | verify | Restrict assertions to a route (live journal, or `--simulate` samples) |
|
|
100
|
+
| `--last-call-within-ms <n>` | verify | Last matching call recency (live journal only) |
|
|
101
|
+
| `--body-contains <text>` | verify | Matching response body substring (live journal last call, or `--simulate` samples) |
|
|
102
|
+
| `--simulate` | verify | Offline corpus instead of live journal |
|
|
103
|
+
| `--port <n>` | start | Port override for the first server; later servers increment |
|
|
104
|
+
| `--control-base <url>` | start, verify | Companion base (default `http://127.0.0.1:3001`) |
|
|
105
|
+
| `--wait-ready` | start | Stay alive until SIGINT/SIGTERM, then stop (implied for `--standalone`) |
|
|
106
|
+
| `--standalone` | start | In-process listeners (no companion) |
|
|
107
|
+
|
|
108
|
+
## Common Options
|
|
109
|
+
|
|
110
|
+
### Test Run Options
|
|
111
|
+
|
|
112
|
+
| Option | Description |
|
|
113
|
+
|--------|-------------|
|
|
114
|
+
| `-c, --concurrency <n>` | Number of concurrent requests (default: 1) |
|
|
115
|
+
| `-i, --iterations <n>` | Number of iterations |
|
|
116
|
+
| `-m, --mode <mode>` | Execution mode: `sequential`, `batch`, `pool`, `load-profile` |
|
|
117
|
+
| `--timeout <sec>` | Per-request timeout in seconds (default: 30) |
|
|
118
|
+
| `--retries <n>` | Retry count on failure |
|
|
119
|
+
| `--retry-delay <ms>` | Delay between retries |
|
|
120
|
+
| `--base-url <url>` | Override base URL for all tests |
|
|
121
|
+
|
|
122
|
+
### Workflow Options
|
|
123
|
+
|
|
124
|
+
| Option | Description |
|
|
125
|
+
|--------|-------------|
|
|
126
|
+
| `-i, --iterations <n>` | Total workflow iterations (default: 10) |
|
|
127
|
+
| `-c, --concurrency <n>` | Concurrent iterations (default: 1) |
|
|
128
|
+
| `--var <name=value>` | Set workflow variables (can repeat) |
|
|
129
|
+
|
|
130
|
+
### Output Options
|
|
131
|
+
|
|
132
|
+
| Option | Description |
|
|
133
|
+
|--------|-------------|
|
|
134
|
+
| `-o, --output <path>` | Write JSON report |
|
|
135
|
+
| `--junit <path>` | Write JUnit XML report |
|
|
136
|
+
| `--markdown <path>` | Write Markdown report |
|
|
137
|
+
| `-q, --quiet` | Suppress progress output |
|
|
138
|
+
|
|
139
|
+
### CI/CD Options
|
|
140
|
+
|
|
141
|
+
| Option | Description |
|
|
142
|
+
|--------|-------------|
|
|
143
|
+
| `--fail-on-error` | Exit code 1 if any request fails |
|
|
144
|
+
| `--fail-threshold <pct>` | Exit code 1 if error rate exceeds % |
|
|
145
|
+
| `--error-policy <policy>` | `continue`, `stop-first`, `stop-threshold` |
|
|
146
|
+
|
|
147
|
+
## Test File Format (YAML)
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
name: My API Tests
|
|
151
|
+
baseUrl: https://api.example.com
|
|
152
|
+
|
|
153
|
+
tests:
|
|
154
|
+
- name: List Users
|
|
155
|
+
method: GET
|
|
156
|
+
url: /users
|
|
157
|
+
assertions:
|
|
158
|
+
- type: status
|
|
159
|
+
expected: "200"
|
|
160
|
+
- type: jsonPath
|
|
161
|
+
jsonPath: $.length
|
|
162
|
+
operator: ">"
|
|
163
|
+
value: 0
|
|
164
|
+
|
|
165
|
+
- name: Create User
|
|
166
|
+
method: POST
|
|
167
|
+
url: /users
|
|
168
|
+
headers:
|
|
169
|
+
Content-Type: application/json
|
|
170
|
+
body: |
|
|
171
|
+
{"name": "{{name}}", "email": "{{email}}"}
|
|
172
|
+
assertions:
|
|
173
|
+
- type: status
|
|
174
|
+
expected: "201"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Workflow File Format (YAML)
|
|
178
|
+
|
|
179
|
+
```yaml
|
|
180
|
+
name: User Registration Flow
|
|
181
|
+
variables:
|
|
182
|
+
email: test@example.com
|
|
183
|
+
|
|
184
|
+
nodes:
|
|
185
|
+
- id: start
|
|
186
|
+
type: start
|
|
187
|
+
data:
|
|
188
|
+
label: Start
|
|
189
|
+
|
|
190
|
+
- id: create-user
|
|
191
|
+
type: http
|
|
192
|
+
data:
|
|
193
|
+
label: Create User
|
|
194
|
+
method: POST
|
|
195
|
+
url: https://api.example.com/users
|
|
196
|
+
headers:
|
|
197
|
+
Content-Type: application/json
|
|
198
|
+
body: |
|
|
199
|
+
{"email": "{{email}}"}
|
|
200
|
+
|
|
201
|
+
edges:
|
|
202
|
+
- id: e1
|
|
203
|
+
source: start
|
|
204
|
+
target: create-user
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Exit Codes
|
|
208
|
+
|
|
209
|
+
| Code | Meaning |
|
|
210
|
+
|------|---------|
|
|
211
|
+
| 0 | Success — all tests passed |
|
|
212
|
+
| 1 | Test failure — some requests failed or threshold exceeded |
|
|
213
|
+
| 2 | Error — invalid file, missing file, or execution error |
|
|
214
|
+
|
|
215
|
+
## CI/CD Example
|
|
216
|
+
|
|
217
|
+
```yaml
|
|
218
|
+
# GitHub Actions
|
|
219
|
+
- name: Run API Tests
|
|
220
|
+
run: |
|
|
221
|
+
npx redfireforge-cli run tests/api-test.yaml \
|
|
222
|
+
--concurrency 10 \
|
|
223
|
+
--iterations 100 \
|
|
224
|
+
--junit results.xml \
|
|
225
|
+
--fail-on-error \
|
|
226
|
+
-q
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Links
|
|
230
|
+
|
|
231
|
+
- [Full Documentation](https://github.com/your-org/redfireforge/blob/main/docs/guides/cli-reference.md)
|
|
232
|
+
- [CI/CD Integration Guide](https://github.com/your-org/redfireforge/blob/main/docs/guides/cli-ci-cd.md)
|
|
233
|
+
- [Example Test Files](https://github.com/your-org/redfireforge/tree/main/examples)
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
MIT
|