Skip to content

Commit fe09084

Browse files
committed
Missing Performance Tests
1 parent 748f86e commit fe09084

8 files changed

Lines changed: 2608 additions & 15 deletions

File tree

tests/PERFORMANCE_TESTING_PLAN.md

Lines changed: 747 additions & 0 deletions
Large diffs are not rendered by default.

tests/k6-load-tests/README.md

Lines changed: 139 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,164 @@
1-
# Load Testing
1+
# Load Testing & Performance Tests
22

3-
This directory contains load testing scripts using k6 (https://k6.io/).
3+
This directory contains comprehensive load testing and performance benchmarking scripts using k6 (https://k6.io/).
4+
5+
## Overview
6+
7+
Our performance testing suite includes:
8+
9+
- **API Benchmarks** - Standard performance baselines for all endpoints
10+
- **Payment Stress Tests** - High-volume payment processing under various loads
11+
- **Memory Profiling** - Detect memory leaks and optimize heap usage
12+
- **Regression Tests** - Automated performance regression detection
13+
- **High Load Tests** - Spike and breakpoint testing to find system limits
14+
- **Edge Case Tests** - Boundary conditions and error scenarios
415

516
## Setup
617

7-
Install k6:
18+
### Install k6
19+
820
```bash
921
# macOS
1022
brew install k6
1123

12-
# Linux
24+
# Linux (Ubuntu/Debian)
1325
sudo apt-get install k6
1426

15-
# Or use Docker
27+
# Windows (via Chocolatey)
28+
choco install k6
29+
30+
# Docker
1631
docker run -i grafana/k6
1732
```
1833

19-
## Tests
34+
### Start Monitoring Stack (Optional)
2035

21-
- **chaos-test.js** - Spike testing to verify system recovery
22-
- **notification-flow.js** - WebSocket connection testing with ramping load
23-
- **payment-flow.js** - Payment API testing with error tracking
36+
For real-time metrics visualization:
2437

25-
## Running Tests
38+
```bash
39+
# Start InfluxDB and Grafana
40+
docker-compose up -d
2641

42+
# Access Grafana at http://localhost:3000
43+
# Default credentials: admin / admin
44+
```
45+
46+
## Test Scenarios
47+
48+
### Performance Benchmarks
49+
50+
**api-benchmark.js** - Comprehensive API performance testing
51+
```bash
52+
k6 run api-benchmark.js
53+
# Tests: Light, Standard, and Heavy load scenarios
54+
# Duration: ~8 minutes
55+
# VUs: 5-100 concurrent users
56+
```
57+
58+
**payment-stress.js** - Payment processing under stress
59+
```bash
60+
k6 run payment-stress.js
61+
# Tests: Normal load, Spike test, Breakpoint test
62+
# Duration: ~7 minutes
63+
# Rate: 10-500 requests/second
64+
```
65+
66+
**memory-profile.js** - Memory leak detection and profiling
67+
```bash
68+
k6 run memory-profile.js
69+
# Tests: Soak test, Memory spike
70+
# Duration: ~12 minutes
71+
# Monitors: RSS, Heap size, GC pauses, Cache hits
72+
```
73+
74+
### Regression Testing
75+
76+
**regression-test.js** - Performance regression detection
77+
```bash
78+
# Quick check (CI/CD)
79+
k6 run regression-test.js
80+
81+
# With custom baselines
82+
BASELINE_P95=500 BASELINE_P99=1000 k6 run regression-test.js
83+
# Duration: ~10 minutes
84+
# Compares against baseline thresholds
85+
```
86+
87+
### High Load Testing
88+
89+
**high-load-test.js** - Extreme load scenarios
90+
```bash
91+
k6 run high-load-test.js
92+
# Tests: Spike (10x traffic), Breakpoint (find limits)
93+
# Duration: ~8 minutes
94+
# Max VUs: 500-1000 concurrent users
95+
```
96+
97+
### Real-time & WebSockets
98+
99+
**notification-flow.js** - WebSocket scaling
27100
```bash
28-
k6 run chaos-test.js
29101
k6 run notification-flow.js
30-
k6 run payment-flow.js
102+
# Tests: 50 concurrent WebSocket connections
103+
# Duration: ~2 minutes
104+
# Monitors: Connection time, Message latency
105+
```
106+
107+
### Chaos & Edge Cases
108+
109+
**chaos-test.js** - Traffic spike recovery
110+
```bash
111+
k6 run chaos-test.js
112+
# Tests: System resilience under sudden load
113+
# Duration: ~3 minutes
31114
```
32115

33-
## Docker
116+
**edge-case-tests.js** - Boundary conditions
117+
```bash
118+
k6 run edge-case-tests.js
119+
# Tests: Min/max values, Zero amounts, Invalid auth, Timeouts
120+
# Duration: ~5 minutes
121+
```
122+
123+
## Running Tests
124+
125+
### Basic Execution
126+
127+
```bash
128+
# Run a single test
129+
k6 run api-benchmark.js
130+
131+
# Run with custom environment variables
132+
BASELINE_P95=500 BASELINE_P99=1000 k6 run regression-test.js
133+
134+
# Run with JSON output
135+
k6 run --out json=results.json api-benchmark.js
136+
137+
# Run with summary export
138+
k6 run --summary-export=summary.json payment-stress.js
139+
```
140+
141+
### Docker Execution
142+
143+
```bash
144+
# Run tests in Docker
145+
docker run -v $(pwd):/scripts grafana/k6 run /scripts/api-benchmark.js
146+
147+
# With InfluxDB output
148+
docker run -v $(pwd):/scripts \
149+
--network host \
150+
grafana/k6 run \
151+
--out influxdb=http://localhost:8086/k6 \
152+
/scripts/payment-stress.js
153+
```
154+
155+
### Automated Test Suite
156+
157+
Run all performance tests sequentially:
34158

35-
Run tests in Docker:
36159
```bash
37-
docker run -v $(pwd):/scripts grafana/k6 run /scripts/chaos-test.js
160+
chmod +x run-performance-tests.sh
161+
./run-performance-tests.sh
38162
```
39163

40164
## Configuration

0 commit comments

Comments
 (0)