word-stress 1.0.0
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/.env.example +8 -0
- package/.instructions.md +361 -0
- package/CHANGELOG.md +88 -0
- package/PUBLISHING.md +103 -0
- package/README.md +120 -0
- package/bin/word-stress +29 -0
- package/package.json +51 -0
- package/src/cli/commands.js +57 -0
- package/src/config.js +159 -0
- package/src/formatters/CsvFormatter.js +72 -0
- package/src/formatters/JsonFormatter.js +17 -0
- package/src/formatters/TableFormatter.js +95 -0
- package/src/formatters/factory.js +31 -0
- package/src/http/client.js +111 -0
- package/src/logger.js +59 -0
- package/src/main.js +75 -0
- package/src/metrics/MetricsCollector.js +169 -0
- package/src/test-modes/BurstTestMode.js +68 -0
- package/src/test-modes/SteadyStateTestMode.js +102 -0
- package/src/test-modes/factory.js +28 -0
- package/src/user-agent.js +51 -0
- package/src/utils.js +99 -0
package/.env.example
ADDED
package/.instructions.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# word-stress Project Instructions
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
**word-stress** is a command-line tool for stress-testing WordPress and WooCommerce sites. It measures two critical performance metrics:
|
|
6
|
+
|
|
7
|
+
1. **Steady-State Throughput**: Maximum sustained request rate with multiple parallel clients polling periodically
|
|
8
|
+
2. **Burst Capacity**: Maximum instantaneous load the server can handle
|
|
9
|
+
|
|
10
|
+
This helps identify performance bottlenecks, saturation points, and failure thresholds.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Architecture & Design
|
|
15
|
+
|
|
16
|
+
### Test Modes
|
|
17
|
+
|
|
18
|
+
#### 1. Steady-State Testing (Default)
|
|
19
|
+
Multiple clients make periodic requests at a fixed interval over a duration.
|
|
20
|
+
|
|
21
|
+
**Parameters:**
|
|
22
|
+
- `--clients` (default: 5) - Number of parallel clients
|
|
23
|
+
- `--interval` (default: 1000) - Milliseconds between each client's requests
|
|
24
|
+
- `--duration` (default: 60) - Test duration in seconds
|
|
25
|
+
- `--endpoint` (default: `/`) - URL path to test
|
|
26
|
+
- `--method` (default: GET) - HTTP method
|
|
27
|
+
- `--https` (default: on) - Enable/disable HTTPS
|
|
28
|
+
|
|
29
|
+
**Behavior:**
|
|
30
|
+
Each client independently:
|
|
31
|
+
1. Makes a request
|
|
32
|
+
2. Waits for response (or timeout)
|
|
33
|
+
3. Waits until interval has elapsed since request start
|
|
34
|
+
4. Repeats until duration expires
|
|
35
|
+
|
|
36
|
+
**Example:**
|
|
37
|
+
```bash
|
|
38
|
+
# 5 clients × 60 requests (1000ms interval × 60s) = ~300 total requests
|
|
39
|
+
word-stress example.com
|
|
40
|
+
|
|
41
|
+
# WooCommerce AJAX endpoint
|
|
42
|
+
word-stress --clients=10 --interval=500 \
|
|
43
|
+
--endpoint='/?wc-ajax=get_refreshed_fragments' --method=POST example.com
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### 2. Burst Testing
|
|
47
|
+
Simultaneous requests to measure peak instantaneous capacity.
|
|
48
|
+
|
|
49
|
+
**Parameters:**
|
|
50
|
+
- `--mode=burst` - Enable burst testing
|
|
51
|
+
- `--burst-clients` (required) - Number of simultaneous requests
|
|
52
|
+
- `--endpoint` (default: `/`) - URL path to test
|
|
53
|
+
- `--method` (default: GET) - HTTP method
|
|
54
|
+
- `--https` (default: on) - Enable/disable HTTPS
|
|
55
|
+
|
|
56
|
+
**Behavior:**
|
|
57
|
+
1. Launch all requests simultaneously
|
|
58
|
+
2. Measure response times and status codes
|
|
59
|
+
3. Record timeouts and errors
|
|
60
|
+
4. Report aggregate metrics
|
|
61
|
+
|
|
62
|
+
**Example:**
|
|
63
|
+
```bash
|
|
64
|
+
# 50 simultaneous requests
|
|
65
|
+
word-stress --mode=burst --burst-clients=50 example.com
|
|
66
|
+
|
|
67
|
+
# 1000 simultaneous AJAX requests
|
|
68
|
+
word-stress --mode=burst --burst-clients=1000 \
|
|
69
|
+
--endpoint='/?wc-ajax=get_refreshed_fragments' --method=POST example.com
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### 3. Spike-and-Decay Testing (Future Enhancement)
|
|
73
|
+
Simulates traffic spikes that gradually tail off to a higher steady state. Useful for real-world patterns like flash sales or viral content.
|
|
74
|
+
|
|
75
|
+
### Global Parameters
|
|
76
|
+
|
|
77
|
+
- `--timeout` (default: 30000) - Request timeout in milliseconds
|
|
78
|
+
- `--follow-redirects` (default: true) - Follow HTTP redirects
|
|
79
|
+
- `--output` (default: table | options: json, csv) - Output format
|
|
80
|
+
- `--https` (default: on) - Enable/disable HTTPS
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## CLI Framework Design
|
|
85
|
+
|
|
86
|
+
### Technology Stack
|
|
87
|
+
|
|
88
|
+
**Command Parsing:**
|
|
89
|
+
- `commander` - Industry standard, simple API, excellent for subcommands
|
|
90
|
+
|
|
91
|
+
**Interactive Prompts:**
|
|
92
|
+
- `inquirer` - For future interactive configuration setup
|
|
93
|
+
|
|
94
|
+
**Terminal Output:**
|
|
95
|
+
- `chalk` - Terminal string styling and colors
|
|
96
|
+
- `ora` - Progress spinners
|
|
97
|
+
- `cli-table3` - Pretty unicode tables for results
|
|
98
|
+
|
|
99
|
+
**Configuration:**
|
|
100
|
+
- `dotenv` - Load environment variables from .env files
|
|
101
|
+
|
|
102
|
+
**HTTP Requests:**
|
|
103
|
+
- Node.js built-in **Fetch API** - For HTTP requests (no axios needed initially)
|
|
104
|
+
|
|
105
|
+
**Logging:**
|
|
106
|
+
- Simple custom logger wrapping `console.log()` and `console.error()`
|
|
107
|
+
|
|
108
|
+
### Command Structure
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
word-stress <domain> [options]
|
|
112
|
+
|
|
113
|
+
Commands:
|
|
114
|
+
word-stress help Show help
|
|
115
|
+
word-stress --version Show version
|
|
116
|
+
|
|
117
|
+
Options:
|
|
118
|
+
Steady-State Mode:
|
|
119
|
+
--clients <n> Number of parallel clients (default: 5)
|
|
120
|
+
--interval <ms> Request interval in ms (default: 1000)
|
|
121
|
+
--duration <s> Test duration in seconds (default: 60)
|
|
122
|
+
|
|
123
|
+
Burst Mode:
|
|
124
|
+
--mode=burst Enable burst testing
|
|
125
|
+
--burst-clients <n> Number of simultaneous requests (required)
|
|
126
|
+
|
|
127
|
+
Common:
|
|
128
|
+
--endpoint <path> URL path to test (default: /)
|
|
129
|
+
--method <METHOD> HTTP method (default: GET)
|
|
130
|
+
--https <on|off> Use HTTPS (default: on)
|
|
131
|
+
--timeout <ms> Request timeout (default: 30000)
|
|
132
|
+
--output <format> Output format: table|json|csv (default: table)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Centralized Configuration
|
|
136
|
+
|
|
137
|
+
All environment variables and defaults are normalized in a single config module:
|
|
138
|
+
- Loads and validates configuration at startup
|
|
139
|
+
- Provides type-safe configuration object
|
|
140
|
+
- Makes testing easier (mock config, not `process.env`)
|
|
141
|
+
- Clear defaults visible in one place
|
|
142
|
+
|
|
143
|
+
**Example structure:**
|
|
144
|
+
```javascript
|
|
145
|
+
// src/config.js
|
|
146
|
+
module.exports = {
|
|
147
|
+
// Test parameters
|
|
148
|
+
clients: process.env.WS_CLIENTS || 5,
|
|
149
|
+
interval: process.env.WS_INTERVAL || 1000,
|
|
150
|
+
duration: process.env.WS_DURATION || 60,
|
|
151
|
+
// ...
|
|
152
|
+
};
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Metrics & Collection
|
|
158
|
+
|
|
159
|
+
### Per-Request Metrics
|
|
160
|
+
- Response time (ms)
|
|
161
|
+
- HTTP status code
|
|
162
|
+
- Response size (bytes)
|
|
163
|
+
- Error type (timeout, network error, etc.)
|
|
164
|
+
|
|
165
|
+
### Aggregate Metrics
|
|
166
|
+
- Total requests sent
|
|
167
|
+
- Successful responses (2xx, 4xx, 5xx counts and percentages)
|
|
168
|
+
- Timeout count
|
|
169
|
+
- Response time percentiles (min, max, avg, median, P95, P99)
|
|
170
|
+
- Requests per second (actual throughput)
|
|
171
|
+
- Total data transferred
|
|
172
|
+
- Test duration
|
|
173
|
+
|
|
174
|
+
### Future Enhancements
|
|
175
|
+
- Time-series data (response times over time)
|
|
176
|
+
- Error rate degradation patterns
|
|
177
|
+
- Throughput trends
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Output Format
|
|
182
|
+
|
|
183
|
+
### Default: Console Tables
|
|
184
|
+
|
|
185
|
+
Pretty-formatted output showing:
|
|
186
|
+
- Test configuration summary
|
|
187
|
+
- Status code distribution table
|
|
188
|
+
- Response time statistics table
|
|
189
|
+
- Throughput metrics
|
|
190
|
+
|
|
191
|
+
**Example:**
|
|
192
|
+
```
|
|
193
|
+
═══════════════════════════════════════════════════════
|
|
194
|
+
Stress Test Results
|
|
195
|
+
═══════════════════════════════════════════════════════
|
|
196
|
+
|
|
197
|
+
Target: https://example.com
|
|
198
|
+
Test Mode: Steady-State
|
|
199
|
+
Duration: 60.2s
|
|
200
|
+
Clients: 5
|
|
201
|
+
Interval: 1000ms
|
|
202
|
+
Total Requests: 300
|
|
203
|
+
|
|
204
|
+
┌─────────────────────┬──────────────┐
|
|
205
|
+
│ Metric │ Value │
|
|
206
|
+
├─────────────────────┼──────────────┤
|
|
207
|
+
│ Successful (2xx) │ 298 (99.3%) │
|
|
208
|
+
│ Client Error (4xx) │ 0 (0%) │
|
|
209
|
+
│ Server Error (5xx) │ 2 (0.7%) │
|
|
210
|
+
│ Timeouts │ 0 (0%) │
|
|
211
|
+
└─────────────────────┴──────────────┘
|
|
212
|
+
|
|
213
|
+
Response Times (ms):
|
|
214
|
+
┌─────────┬──────────┐
|
|
215
|
+
│ Min │ 89 │
|
|
216
|
+
│ Max │ 2156 │
|
|
217
|
+
│ Avg │ 245 │
|
|
218
|
+
│ Median │ 198 │
|
|
219
|
+
│ P95 │ 567 │
|
|
220
|
+
│ P99 │ 1234 │
|
|
221
|
+
└─────────┴──────────┘
|
|
222
|
+
|
|
223
|
+
Throughput: 4.98 req/s
|
|
224
|
+
Data Transferred: 2.1 MB
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### JSON Export
|
|
228
|
+
Machine-readable format for analysis tools and spreadsheets.
|
|
229
|
+
|
|
230
|
+
### CSV Export
|
|
231
|
+
For spreadsheet analysis and comparing multiple test runs.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Implementation Decisions
|
|
236
|
+
|
|
237
|
+
### Decision: Fetch API over Axios
|
|
238
|
+
**Rationale:** Node.js now has built-in Fetch API support. Start with built-in to minimize dependencies. Switch to axios only if we need advanced features (interceptors, request/response transformation).
|
|
239
|
+
|
|
240
|
+
### Decision: Simple Logger over Winston/Pino
|
|
241
|
+
**Rationale:** Avoid heavy logging frameworks. Implement a simple custom logger wrapping `console.log()` and `console.error()` with `LOG_LEVEL` support. Keeps the project lightweight.
|
|
242
|
+
|
|
243
|
+
### Decision: Table Output First, Live UI Later
|
|
244
|
+
**Rationale:** Start with simple final-report tables using `cli-table3`. Live updating UI deferred to future enhancement. Reduces initial complexity while still providing useful output.
|
|
245
|
+
|
|
246
|
+
### Decision: No Authentication in Phase 1
|
|
247
|
+
**Rationale:** Test AJAX endpoints and public endpoints without authentication. Authentication support (basic auth, cookies, tokens) deferred to future phases.
|
|
248
|
+
|
|
249
|
+
### Decision: Metrics Streaming, Not Stored
|
|
250
|
+
**Rationale:** Don't store full response bodies or all request details in memory. Calculate percentiles and aggregate metrics incrementally. Save memory for long-running tests.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Development Workflows
|
|
255
|
+
|
|
256
|
+
### Adding a New Test Mode
|
|
257
|
+
|
|
258
|
+
1. Add mode to CLI with `commander` in `src/cli/commands.js`
|
|
259
|
+
2. Create test mode class in `src/test-modes/` (e.g., `SpikeDayTestMode.js`)
|
|
260
|
+
3. Implement `run()` method that:
|
|
261
|
+
- Spawns clients/requests
|
|
262
|
+
- Collects metrics
|
|
263
|
+
- Returns aggregated results
|
|
264
|
+
4. Add test mode to factory in `src/test-modes/factory.js`
|
|
265
|
+
5. Document in `.instructions.md` and `dev-notes/02-stress-test-requirements.md`
|
|
266
|
+
|
|
267
|
+
### Adding a New Output Format
|
|
268
|
+
|
|
269
|
+
1. Create formatter in `src/formatters/` (e.g., `XMLFormatter.js`)
|
|
270
|
+
2. Implement `format(results)` method
|
|
271
|
+
3. Add formatter to factory in `src/formatters/factory.js`
|
|
272
|
+
4. Update CLI `--output` options
|
|
273
|
+
|
|
274
|
+
### Adding Metrics Collection
|
|
275
|
+
|
|
276
|
+
1. Update `MetricsCollector` class
|
|
277
|
+
2. Add per-request metric calculation
|
|
278
|
+
3. Update aggregate calculation
|
|
279
|
+
4. Update output formatters to display new metrics
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Module Structure (Planned)
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
src/
|
|
287
|
+
├── bin/word-stress # Executable entry point
|
|
288
|
+
├── cli/
|
|
289
|
+
│ ├── commands.js # Commander.js setup
|
|
290
|
+
│ └── help.js # Help text
|
|
291
|
+
├── config.js # Centralized configuration
|
|
292
|
+
├── test-modes/
|
|
293
|
+
│ ├── SteadyStateTestMode.js # Steady-state implementation
|
|
294
|
+
│ ├── BurstTestMode.js # Burst implementation
|
|
295
|
+
│ └── factory.js # Test mode factory
|
|
296
|
+
├── http/
|
|
297
|
+
│ └── client.js # HTTP request handling
|
|
298
|
+
├── metrics/
|
|
299
|
+
│ └── MetricsCollector.js # Metrics aggregation
|
|
300
|
+
├── formatters/
|
|
301
|
+
│ ├── TableFormatter.js # Pretty table output
|
|
302
|
+
│ ├── JsonFormatter.js # JSON export
|
|
303
|
+
│ ├── CsvFormatter.js # CSV export
|
|
304
|
+
│ └── factory.js # Formatter factory
|
|
305
|
+
├── logger.js # Custom logger
|
|
306
|
+
└── main.js # Application entry point
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Error Handling
|
|
312
|
+
|
|
313
|
+
### Request Errors
|
|
314
|
+
- Network errors → Record as "Network Error"
|
|
315
|
+
- Timeouts → Record as timeout, increment timeout counter
|
|
316
|
+
- HTTP errors (4xx, 5xx) → Record status code, count by category
|
|
317
|
+
|
|
318
|
+
### Behavior
|
|
319
|
+
- Continue testing even if individual requests fail
|
|
320
|
+
- Never abort test due to errors
|
|
321
|
+
- Track and report error patterns
|
|
322
|
+
|
|
323
|
+
### Reporting
|
|
324
|
+
- Distinguish error types in output
|
|
325
|
+
- Report error percentages
|
|
326
|
+
- Highlight concerning error patterns (e.g., >10% error rate)
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Testing & Quality
|
|
331
|
+
|
|
332
|
+
### Unit Tests
|
|
333
|
+
- Test metrics calculation (percentiles, aggregates)
|
|
334
|
+
- Test formatters with sample data
|
|
335
|
+
- Test configuration validation
|
|
336
|
+
|
|
337
|
+
### Integration Tests
|
|
338
|
+
- Mock HTTP requests, test full test-mode flow
|
|
339
|
+
- Test CLI parameter parsing
|
|
340
|
+
- Test output formatting
|
|
341
|
+
|
|
342
|
+
### Manual Testing
|
|
343
|
+
- Run against local WordPress/WooCommerce installation
|
|
344
|
+
- Verify steady-state behavior matches expectations
|
|
345
|
+
- Verify burst requests all send simultaneously
|
|
346
|
+
- Verify output formatting accuracy
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Next Steps
|
|
351
|
+
|
|
352
|
+
1. ✅ Define requirements and test modes
|
|
353
|
+
2. ✅ Select dependencies
|
|
354
|
+
3. ✅ Design CLI interface
|
|
355
|
+
4. → Set up CLI framework with commander
|
|
356
|
+
5. → Implement HTTP client with Fetch API
|
|
357
|
+
6. → Implement steady-state test mode
|
|
358
|
+
7. → Implement burst test mode
|
|
359
|
+
8. → Build metrics collector
|
|
360
|
+
9. → Create output formatters
|
|
361
|
+
10. → Add comprehensive testing
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-01-07
|
|
9
|
+
|
|
10
|
+
### Added - Phase 1: Project Setup
|
|
11
|
+
- Initial project scaffolding with proper directory structure
|
|
12
|
+
- Git repository initialization with comprehensive .gitignore
|
|
13
|
+
- npm package configuration with Node.js 21+ requirement
|
|
14
|
+
- AI instruction files (.github/copilot-instructions.md, .instructions.md)
|
|
15
|
+
|
|
16
|
+
### Added - Phase 2: CLI Framework
|
|
17
|
+
- Commander.js CLI with full parameter parsing and validation
|
|
18
|
+
- Centralized configuration module with environment variable support
|
|
19
|
+
- Custom logger with LOG_LEVEL support
|
|
20
|
+
- Comprehensive help and version output
|
|
21
|
+
- All CLI parameters: clients, interval, duration, mode, burst-clients, endpoint, method, https, timeout, follow-redirects, output, verbose
|
|
22
|
+
|
|
23
|
+
### Added - Phase 3: HTTP Client
|
|
24
|
+
- Native Fetch API HTTP client with timeout handling (AbortController)
|
|
25
|
+
- Request methods: GET, POST, PUT, DELETE, PATCH
|
|
26
|
+
- Error classification: network errors, timeouts, HTTP errors
|
|
27
|
+
- Response size tracking and calculation
|
|
28
|
+
- Response time measurement in milliseconds
|
|
29
|
+
- Redirect handling support
|
|
30
|
+
|
|
31
|
+
### Added - Phase 4: Metrics Collection
|
|
32
|
+
- MetricsCollector class with per-request and aggregate metrics
|
|
33
|
+
- Response time statistics: min, max, average, median, P95, P99
|
|
34
|
+
- Status code distribution tracking (2xx, 3xx, 4xx, 5xx)
|
|
35
|
+
- Error tracking and classification
|
|
36
|
+
- Throughput calculation (requests/second)
|
|
37
|
+
- Data transferred measurement
|
|
38
|
+
- Success rate calculation
|
|
39
|
+
|
|
40
|
+
### Added - Phase 5: Steady-State Test Mode
|
|
41
|
+
- Multiple concurrent clients with independent request scheduling
|
|
42
|
+
- Fixed interval-based request timing (configurable milliseconds)
|
|
43
|
+
- Duration-based testing (configurable seconds)
|
|
44
|
+
- Graceful handling of timing and request synchronization
|
|
45
|
+
- Full integration with HTTP client and metrics collection
|
|
46
|
+
|
|
47
|
+
### Added - Phase 6: Burst Test Mode
|
|
48
|
+
- Simultaneous request launching with Promise.all()
|
|
49
|
+
- Peak capacity measurement
|
|
50
|
+
- Concurrent request handling without timing constraints
|
|
51
|
+
- Error tracking during burst loads
|
|
52
|
+
|
|
53
|
+
### Added - Phase 7: Output Formatters
|
|
54
|
+
- TableFormatter: Beautiful ASCII tables using cli-table3
|
|
55
|
+
- Summary metrics table
|
|
56
|
+
- Response time statistics table with percentiles
|
|
57
|
+
- Status code distribution table
|
|
58
|
+
- Error details table (when applicable)
|
|
59
|
+
- JsonFormatter: Pretty-printed JSON output for programmatic parsing
|
|
60
|
+
- CsvFormatter: CSV format with proper escaping for spreadsheet import
|
|
61
|
+
|
|
62
|
+
### Added - User Agent Support
|
|
63
|
+
- Browser presets: Firefox, Chrome, Safari with realistic user agent strings
|
|
64
|
+
- Custom user agent support via --user-agent parameter
|
|
65
|
+
- user-agents npm package for up-to-date browser user agents
|
|
66
|
+
- Proper User-Agent header in all HTTP requests
|
|
67
|
+
|
|
68
|
+
### Added - Code Quality
|
|
69
|
+
- ESLint with recommended rules for Node.js
|
|
70
|
+
- Prettier for automatic code formatting
|
|
71
|
+
- npm scripts: format, format:check, lint, lint:fix, test, audit
|
|
72
|
+
- All code passing linting and formatting standards
|
|
73
|
+
- Zero security vulnerabilities
|
|
74
|
+
|
|
75
|
+
### Added - Documentation
|
|
76
|
+
- Comprehensive README with usage examples
|
|
77
|
+
- Portable Node.js CLI development standards in .github/copilot-instructions.md
|
|
78
|
+
- Architecture and design documentation in .instructions.md
|
|
79
|
+
- Project tracker in dev-notes/00-project-tracker.md
|
|
80
|
+
|
|
81
|
+
### Testing
|
|
82
|
+
- Tested against local WordPress installation (http://leyland.local/)
|
|
83
|
+
- Burst testing: 90+ req/s throughput with 100% success rate
|
|
84
|
+
- Steady-state testing: Proper interval-based scheduling verified
|
|
85
|
+
- All three output formats tested and working
|
|
86
|
+
- User agent headers verified in server access logs
|
|
87
|
+
|
|
88
|
+
[1.0.0]: https://github.com/headwalluk/word-stress/releases/tag/v1.0.0
|
package/PUBLISHING.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Publishing to npm
|
|
2
|
+
|
|
3
|
+
This guide explains how to publish `word-stress` to the npm registry.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
1. Node.js 21+ installed
|
|
8
|
+
2. npm account (you have one at https://www.npmjs.com/~headwall)
|
|
9
|
+
3. Git repository with all changes committed
|
|
10
|
+
|
|
11
|
+
## Publishing Steps
|
|
12
|
+
|
|
13
|
+
### 1. Ensure You're Logged Into npm
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm login
|
|
17
|
+
# Enter your npm username: headwall
|
|
18
|
+
# Enter your password: [your npm password]
|
|
19
|
+
# Enter your email: [your registered email]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 2. Verify Package Details
|
|
23
|
+
|
|
24
|
+
Before publishing, verify the package information:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Check the package will be published correctly
|
|
28
|
+
npm publish --dry-run
|
|
29
|
+
|
|
30
|
+
# Review what files will be included
|
|
31
|
+
npm pack --dry-run
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 3. Publish to npm Registry
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm publish
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This will:
|
|
41
|
+
- Upload `word-stress` to npm registry
|
|
42
|
+
- Make it available at https://www.npmjs.com/package/word-stress
|
|
43
|
+
- Allow users to install via: `npm install -g word-stress` or `npx word-stress`
|
|
44
|
+
|
|
45
|
+
### 4. Verify Publication
|
|
46
|
+
|
|
47
|
+
After publishing, verify it's available:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm info word-stress
|
|
51
|
+
npm view word-stress versions
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 5. Test Installation via npx
|
|
55
|
+
|
|
56
|
+
After publication, anyone with Node.js 21+ can run:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx word-stress --duration 10 example.com
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Updating the Package
|
|
63
|
+
|
|
64
|
+
To release a new version:
|
|
65
|
+
|
|
66
|
+
1. Update version in `package.json`:
|
|
67
|
+
```bash
|
|
68
|
+
npm version patch # for bugfixes (1.0.0 → 1.0.1)
|
|
69
|
+
npm version minor # for features (1.0.0 → 1.1.0)
|
|
70
|
+
npm version major # for breaking changes (1.0.0 → 2.0.0)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2. Create git tag:
|
|
74
|
+
```bash
|
|
75
|
+
git tag -a v1.0.1 -m "Release version 1.0.1"
|
|
76
|
+
git push origin main --tags
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
3. Publish new version:
|
|
80
|
+
```bash
|
|
81
|
+
npm publish
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Package Size Optimization
|
|
85
|
+
|
|
86
|
+
The `.npmignore` file ensures minimal package size by excluding:
|
|
87
|
+
- Development configuration files
|
|
88
|
+
- Development notes
|
|
89
|
+
- Tests
|
|
90
|
+
- GitHub workflows
|
|
91
|
+
- IDE configuration
|
|
92
|
+
|
|
93
|
+
Current estimated package size: ~50KB (with dependencies ~500KB installed)
|
|
94
|
+
|
|
95
|
+
## Reverting a Publication
|
|
96
|
+
|
|
97
|
+
If you need to unpublish a version within 72 hours of publication:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npm unpublish word-stress@1.0.0
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
For production packages, it's better to release a patch version instead of unpublishing.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# word-stress
|
|
2
|
+
|
|
3
|
+
A command-line tool for stress-testing WordPress and WooCommerce sites.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`word-stress` is a performance testing tool designed to identify bottlenecks, saturation points, and failure thresholds in WordPress and WooCommerce installations. It sends configurable parallel requests to measure server capacity and response degradation under load.
|
|
8
|
+
|
|
9
|
+
## Project Status
|
|
10
|
+
|
|
11
|
+
✅ **Version 1.0.0** - Feature complete and production ready!
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- ✅ Steady-state load testing with multiple concurrent clients
|
|
16
|
+
- ✅ Burst capacity testing with simultaneous requests
|
|
17
|
+
- ✅ Configurable intervals, durations, and timeouts
|
|
18
|
+
- ✅ WordPress and WooCommerce endpoint testing (GET/POST/PUT/DELETE/PATCH)
|
|
19
|
+
- ✅ Comprehensive metrics: response times, percentiles (P95, P99), throughput, success rate
|
|
20
|
+
- ✅ Realistic user agent support (Chrome, Firefox, Safari, or custom)
|
|
21
|
+
- ✅ Beautiful ASCII table output
|
|
22
|
+
- ✅ JSON and CSV export formats
|
|
23
|
+
- ✅ HTTP/HTTPS with redirect handling
|
|
24
|
+
- ✅ Request timeout support
|
|
25
|
+
- ✅ Detailed error classification and tracking
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Steady-State Testing
|
|
36
|
+
Tests with multiple parallel clients making periodic requests.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Default: 5 clients, 1000ms interval, 60 second duration
|
|
40
|
+
./bin/word-stress example.com
|
|
41
|
+
|
|
42
|
+
# 10 clients with 500ms interval
|
|
43
|
+
./bin/word-stress --clients=10 --interval=500 example.com
|
|
44
|
+
|
|
45
|
+
# WooCommerce AJAX endpoint
|
|
46
|
+
./bin/word-stress --clients=20 --interval=1000 \
|
|
47
|
+
--endpoint='/?wc-ajax=get_refreshed_fragments' --method=POST example.com
|
|
48
|
+
|
|
49
|
+
# Test local development site without HTTPS
|
|
50
|
+
./bin/word-stress --clients=5 --https=off example.dev
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Burst Testing
|
|
54
|
+
Tests with many simultaneous requests to measure peak capacity.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# 50 simultaneous requests
|
|
58
|
+
./bin/word-stress --mode=burst --burst-clients=50 example.com
|
|
59
|
+
|
|
60
|
+
# 1000 simultaneous AJAX requests
|
|
61
|
+
./bin/word-stress --mode=burst --burst-clients=1000 \
|
|
62
|
+
--endpoint='/?wc-ajax=get_refreshed_fragments' --method=POST example.com
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Output Formats
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Pretty table output (default)
|
|
69
|
+
./bin/word-stress example.com
|
|
70
|
+
|
|
71
|
+
# JSON export
|
|
72
|
+
./bin/word-stress --output=json example.com
|
|
73
|
+
|
|
74
|
+
# CSV export
|
|
75
|
+
./bin/word-stress --output=csv example.com
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Help
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
./bin/word-stress --help
|
|
82
|
+
./bin/word-stress --version
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
See [dev-notes/02-stress-test-requirements.md](dev-notes/02-stress-test-requirements.md) for detailed usage examples and requirements.
|
|
86
|
+
|
|
87
|
+
## Documentation
|
|
88
|
+
|
|
89
|
+
- [docs/](./docs) - Public-facing documentation
|
|
90
|
+
- [dev-notes/](./dev-notes) - Development notes and requirements
|
|
91
|
+
- [.github/copilot-instructions.md](.github/copilot-instructions.md) - AI coding standards
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
### Dependencies
|
|
96
|
+
|
|
97
|
+
- **commander** - Command-line interface
|
|
98
|
+
- **chalk** - Terminal colors
|
|
99
|
+
- **ora** - Progress spinners
|
|
100
|
+
- **cli-table3** - Result tables
|
|
101
|
+
- **dotenv** - Environment configuration
|
|
102
|
+
|
|
103
|
+
### Node Version
|
|
104
|
+
|
|
105
|
+
Requires Node.js 21 or greater for Fetch API support.
|
|
106
|
+
|
|
107
|
+
### Project Structure
|
|
108
|
+
|
|
109
|
+
- `src/` - Source code (config, CLI setup, HTTP client, metrics, test modes, formatters)
|
|
110
|
+
- `bin/` - Executable entry point
|
|
111
|
+
- `dev-notes/` - Development notes and requirements
|
|
112
|
+
- [.instructions.md](.instructions.md) - Project architecture and design decisions
|
|
113
|
+
|
|
114
|
+
### Contributing
|
|
115
|
+
|
|
116
|
+
See [.github/copilot-instructions.md](.github/copilot-instructions.md) for coding standards and best practices.
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT
|
package/bin/word-stress
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* word-stress CLI executable
|
|
5
|
+
* Entry point for the command-line tool
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { setupCli } = require('../src/cli/commands');
|
|
9
|
+
const { main } = require('../src/main');
|
|
10
|
+
|
|
11
|
+
async function run() {
|
|
12
|
+
const program = setupCli();
|
|
13
|
+
|
|
14
|
+
program.action((domain, options) => {
|
|
15
|
+
// Parse arguments and pass to main
|
|
16
|
+
const args = {
|
|
17
|
+
domain,
|
|
18
|
+
...options,
|
|
19
|
+
};
|
|
20
|
+
main(args);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
program.parse(process.argv);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
run().catch(error => {
|
|
27
|
+
console.error('Unexpected error:', error.message);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
});
|