- Add load-test job to ci.yml that runs after docker-build on push to main - Create combined load test runner (scripts/load-test/run-all.sh) for all services - Create k6 load test scripts for api, darkwatch, spamshield, and voiceprint - Add shared k6 utilities (lib/common.js) - Update load-test.yml to support all services and report artifacts - Configure k6 cloud output and P99 threshold validation - Generate load test report as CI artifact Co-Authored-By: Paperclip <noreply@paperclip.ing>
78 lines
2.4 KiB
YAML
78 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 '.metrics | to_entries[] | select(.value.passes == false) | .key' scripts/load-test/reports/threshold-results.json 2>/dev/null || echo "")
|
|
if [ -n "$FAILURES" ]; then
|
|
echo "❌ P99 threshold failures:"
|
|
echo "$FAILURES"
|
|
exit 1
|
|
else
|
|
echo "✅ All P99 thresholds passed"
|
|
fi
|
|
else
|
|
echo "No threshold results file found"
|
|
fi
|