Files
ShieldAI/.github/workflows/load-test.yml
Michael Freno 8506fd17ef Fix load test scenarios, runner, and CI threshold checks
- Add constant-arrival-rate scenarios to all 4 service scripts (api,
  darkwatch, spamshield, voiceprint) to enforce 500 req/s target
- Fix defaultThresholds() to return { thresholds: {...} } so
  http_req_duration and errors thresholds are actually applied
- Rewrite run-all.sh: per-service summary files, proper env var
  passing (DURATION, API_TOKEN), fixed threshold aggregation
- Update CI workflow threshold check jq to match new threshold-results
  structure (.services.<name>.exitCode)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-09 10:35:45 -04:00

77 lines
2.4 KiB
YAML

name: Load Test
on:
push:
branches: [main]
workflow_dispatch:
inputs:
target_rps:
description: 'Target requests per second'
required: false
default: '500'
duration:
description: 'Test duration'
required: false
default: '300s'
service:
description: 'Service to test (all, api, darkwatch, spamshield, voiceprint)'
required: false
default: 'all'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: "20"
jobs:
load-test:
name: Load Test (${{ github.event.inputs.service || 'all' }})
runs-on: ubuntu-latest
timeout-minutes: 30
environment: staging
steps:
- uses: actions/checkout@v4
- name: Install k6
run: |
curl -s https://github.com/grafana/k6/releases/download/v0.50.0/k6-linux-amd64.tar.gz -L | tar xz
sudo mv k6 /usr/local/bin/
k6 version
- name: Run load tests
run: |
chmod +x scripts/load-test/run-all.sh
./scripts/load-test/run-all.sh ${{ github.event.inputs.service || 'all' }}
env:
LOAD_TEST_BASE_URL: ${{ secrets.LOAD_TEST_BASE_URL || 'http://localhost:3000' }}
API_TOKEN: ${{ secrets.LOAD_TEST_API_TOKEN || 'test-token' }}
TARGET_RPS: ${{ github.event.inputs.target_rps || '500' }}
DURATION: ${{ github.event.inputs.duration || '300s' }}
K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN || '' }}
K6_CLOUD_PROJECT_ID: ${{ vars.K6_CLOUD_PROJECT_ID || '' }}
- name: Upload load test report
if: always()
uses: actions/upload-artifact@v4
with:
name: load-test-report-${{ github.sha }}
path: scripts/load-test/reports/
retention-days: 30
- name: Check P99 thresholds
if: always()
run: |
if [ -f scripts/load-test/reports/threshold-results.json ]; then
FAILURES=$(jq -r '[.services | to_entries[] | select(.value.exitCode != 0) | .key] | join(", ")' scripts/load-test/reports/threshold-results.json 2>/dev/null || echo "")
if [ -n "$FAILURES" ] && [ "$FAILURES" != "" ]; then
echo "❌ Load test failures: $FAILURES"
exit 1
else
echo "✅ All load tests passed"
fi
else
echo "⚠️ No threshold results file found"
fi