File size: 871 Bytes
d4d0bc7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Run load test headlessly against a live server.
#
# Environment variables (all optional):
#   HOST        Target host URL         (default: http://localhost:8000)
#   USERS       Peak concurrent users   (default: 50)
#   SPAWN_RATE  Users spawned per sec   (default: 5)
#   RUN_TIME    Total test duration     (default: 120s)
#
# Examples:
#   ./scripts/load_test.sh
#   HOST=https://staging.example.com USERS=100 ./scripts/load_test.sh
#
# HTML + CSV reports are written to reports/.

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"

mkdir -p reports

locust -f tests/locustfile.py \
  --host "${HOST:-http://localhost:8000}" \
  --headless \
  --users "${USERS:-50}" \
  --spawn-rate "${SPAWN_RATE:-5}" \
  --run-time "${RUN_TIME:-120s}" \
  --html reports/load_test_report.html \
  --csv reports/load_test