Load Tests #682
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Load Tests | |
| on: | |
| push: | |
| branches: [main, dev] | |
| pull_request: | |
| branches: [main, dev] | |
| schedule: | |
| - cron: "0 4 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| suite: | |
| description: "Suite to run (smoke or scenarios)" | |
| required: false | |
| default: smoke | |
| type: choice | |
| options: [smoke, scenarios] | |
| jobs: | |
| k6-config: | |
| name: k6 config and production-guard tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Validate k6 scripts | |
| run: python -m pytest -q load-tests/tests | |
| - name: Install k6 | |
| uses: grafana/setup-k6-action@v1 | |
| - name: Production safety guard rejects api.soroscan.io | |
| env: | |
| BASE_URL: https://api.soroscan.io | |
| run: | | |
| if k6 run load-tests/k6/smoke.js; then | |
| echo "expected k6 to abort against production" | |
| exit 1 | |
| fi | |
| k6-smoke: | |
| if: github.event_name != 'schedule' && (github.event_name != 'workflow_dispatch' || github.event.inputs.suite == 'smoke') | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: test_soroscan | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Django dependencies | |
| working-directory: django-backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -r requirements.txt | |
| - name: Start API server | |
| working-directory: django-backend | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_soroscan | |
| REDIS_URL: redis://localhost:6379/0 | |
| SECRET_KEY: test-secret-key-for-ci | |
| DEBUG: "False" | |
| DJANGO_SETTINGS_MODULE: soroscan.settings_test | |
| CELERY_TASK_ALWAYS_EAGER: "True" | |
| SOROBAN_RPC_URL: https://soroban-testnet.stellar.org | |
| STELLAR_NETWORK_PASSPHRASE: "Test SDF Network ; September 2015" | |
| SOROSCAN_CONTRACT_ID: CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM | |
| INDEXER_SECRET_KEY: "" | |
| run: | | |
| python manage.py migrate --noinput | |
| python manage.py runserver 0.0.0.0:8000 & | |
| for i in $(seq 1 30); do | |
| if curl -sf http://127.0.0.1:8000/api/ingest/health/ > /dev/null; then | |
| echo "API ready" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| echo "API failed to start" | |
| exit 1 | |
| - name: Install k6 | |
| uses: grafana/setup-k6-action@v1 | |
| - name: Run smoke load test | |
| env: | |
| BASE_URL: http://127.0.0.1:8000 | |
| K6_VUS: "3" | |
| K6_DURATION: "15s" | |
| K6_REPORT_PATH: load-tests/results/ci-smoke-summary.json | |
| SOROSCAN_ENVIRONMENT: ci | |
| run: | | |
| mkdir -p load-tests/results | |
| k6 run load-tests/k6/smoke.js | |
| - name: Upload load test report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: k6-smoke-report | |
| path: load-tests/results/ci-smoke-summary.json | |
| k6-scenarios: | |
| name: Full k6 scenario suite | |
| if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.suite == 'scenarios') | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: test_soroscan | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install Django dependencies | |
| working-directory: django-backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -r requirements.txt | |
| - name: Start API server | |
| working-directory: django-backend | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test_soroscan | |
| REDIS_URL: redis://localhost:6379/0 | |
| SECRET_KEY: test-secret-key-for-ci | |
| DEBUG: "False" | |
| DJANGO_SETTINGS_MODULE: soroscan.settings_test | |
| CELERY_TASK_ALWAYS_EAGER: "True" | |
| SOROBAN_RPC_URL: https://soroban-testnet.stellar.org | |
| STELLAR_NETWORK_PASSPHRASE: "Test SDF Network ; September 2015" | |
| SOROSCAN_CONTRACT_ID: CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM | |
| INDEXER_SECRET_KEY: "" | |
| run: | | |
| python manage.py migrate --noinput | |
| python manage.py runserver 0.0.0.0:8000 & | |
| for i in $(seq 1 30); do | |
| if curl -sf http://127.0.0.1:8000/api/ingest/health/ > /dev/null; then | |
| echo "API ready" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| echo "API failed to start" | |
| exit 1 | |
| - name: Install k6 | |
| uses: grafana/setup-k6-action@v1 | |
| - name: Run full scenario suite | |
| env: | |
| BASE_URL: http://127.0.0.1:8000 | |
| K6_VUS: "5" | |
| K6_DURATION: "30s" | |
| K6_RAMP_UP: "5s" | |
| K6_REPORT_PATH: load-tests/results/ci-scenarios-summary.json | |
| SOROSCAN_ENVIRONMENT: ci | |
| run: | | |
| mkdir -p load-tests/results | |
| k6 run load-tests/k6/scenarios.js | |
| - name: Upload scenario report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: k6-scenarios-report | |
| path: load-tests/results/ci-scenarios-summary.json |