Files
ShieldAI/load-tests/voiceprint/run.sh
Senior Engineer cb5851ec8c Add k6 load test scripts for Voiceprint verification endpoints (FRE-4930)
- k6 script with P99 latency thresholds (enrollment <500ms, verification <250ms, model retrieval <100ms)
- Configurable 500 req/s sustained throughput for 5 minutes
- Mixed workload scenario + individual endpoint scenarios
- GitHub Actions workflow for automated load testing
- Runner script with environment configuration
- JSON result export for CI artifact collection
- .gitignore entry for load test results
2026-05-09 07:50:29 -04:00

70 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run k6 load tests for Voiceprint endpoints
# Usage: ./run.sh [scenario]
# scenario: mixed (default), enrollment, verification, model-retrieval
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Load environment variables from .env if present
if [[ -f .env ]]; then
set -a
source .env
set +a
fi
SCENARIO="${1:-mixed}"
OUTPUT_DIR="${SCRIPT_DIR}/results"
TIMESTAMP="$(date +%Y%m%d-%H%M%S)"
mkdir -p "$OUTPUT_DIR"
echo "=== Voiceprint Load Test ==="
echo "Scenario: $SCENARIO"
echo "Target RPS: ${TARGET_RPS:-500}"
echo "Duration: ${DURATION:-300s}"
echo "Base URL: ${VOICEPRINT_BASE_URL:-http://localhost:3000}"
echo ""
case "$SCENARIO" in
mixed)
k6 run voiceprint.js \
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" \
<<EOF
EOF
;;
enrollment)
k6 run --scenario enrollment_only voiceprint.js \
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json"
;;
verification)
k6 run --scenario verification_only voiceprint.js \
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json"
;;
model-retrieval)
k6 run --scenario model_retrieval_only voiceprint.js \
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json"
;;
*)
echo "Unknown scenario: $SCENARIO"
echo "Available: mixed, enrollment, verification, model-retrieval"
exit 1
;;
esac
EXIT_CODE=$?
if [[ $EXIT_CODE -eq 0 ]]; then
echo ""
echo "✅ All thresholds passed!"
echo "Results saved to: $OUTPUT_DIR/results-${TIMESTAMP}.json"
else
echo ""
echo "❌ Thresholds failed. Check output above."
echo "Results saved to: $OUTPUT_DIR/results-${TIMESTAMP}.json"
fi
exit $EXIT_CODE