#!/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