Files
PerformanceTests/README.md
T

90 lines
1.8 KiB
Markdown

# K6 Load Tests
Load tests for NowChess using K6 framework.
## Installation
```bash
# Install K6 - https://k6.io/docs/getting-started/installation/
# macOS
brew install k6
# Ubuntu/Debian
sudo apt-get install k6
# Windows (Chocolatey)
choco install k6
```
## Running Tests
### Smoke Test
One user, basic journey validation.
```bash
k6 run simulations/smokeTest.js
```
### Load Test
Ramp up to max users over duration.
```bash
BASE_URL=http://localhost:8080 MAX_USERS=5 RAMP_DURATION=60 k6 run simulations/loadTest.js
```
### Stress Test
Incrementally increase users in steps.
```bash
BASE_URL=http://localhost:8080 \
START_USERS=2 \
USERS_INCREMENT=2 \
STEPS=2 \
STEP_DURATION=30 \
RAMP_DURATION=10 \
k6 run simulations/stressTest.js
```
### Spike Test
Baseline → spike → baseline.
```bash
BASE_URL=http://localhost:8080 \
BASELINE_USERS=2 \
BASELINE_DURATION=20 \
SPIKE_USERS=15 \
k6 run simulations/spikeTest.js
```
### Endurance Test
Constant load over long duration.
```bash
BASE_URL=http://localhost:8080 \
CONCURRENT_USERS=3 \
DURATION=300 \
k6 run simulations/enduranceTest.js
```
## Environment Variables
- `BASE_URL` - API base URL (default: `http://localhost:8080`)
- `AUTH_TOKEN` - Optional Bearer token for global auth
- Test-specific variables documented in each simulation file
## Output
Results summary printed to console. For detailed metrics, use K6 output options:
```bash
# JSON output
k6 run --out json=results.json simulations/smokeTest.js
# Cloud output (requires K6 Cloud account)
k6 run --out cloud simulations/smokeTest.js
# InfluxDB + Grafana
k6 run --out influxdb simulations/smokeTest.js
```
## Structure
- `config.js` - Shared configuration, headers, checks
- `scenarios/` - Reusable scenario definitions
- `simulations/` - Test simulations with load profiles