Skip to content

Load Tests

Load Tests #256

Workflow file for this run

name: Load Tests
on:
push:
repository_dispatch:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
inputs:
server_image:
description: 'Wizard Server image'
required: false
default: 'dswbot/wizard-server:develop'
users:
description: 'Users'
required: false
default: '20'
spawn_rate:
description: 'Spawn Rate'
required: false
default: '5'
run_time:
description: 'Run Time'
required: false
default: '3m'
jobs:
load-test:
name: Load Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test:
- 'package-detail'
- 'packages-list'
- 'questionnaire-clone'
- 'questionnaire-create'
- 'questionnaire-detail'
- 'questionnaire-update'
- 'questionnaires-list'
- 'user-create'
- 'user-register'
- 'user-update'
- 'users-list'
- 'visit-login'
steps:
- name: Set variables from repository dispatch
if: github.event_name == 'repository_dispatch'
uses: allenevans/[email protected]
with:
SERVER_IMAGE: ${{ github.event.client_payload.server_image }}
LOCUST_USERS: ${{ github.event.client_payload.users }}
LOCUST_SPAWN_RATE: ${{ github.event.client_payload.spawn_rate }}
LOCUST_RUN_TIME: ${{ github.event.client_payload.run_time }}
- name: Set variables from workflow dispatch
if: github.event_name == 'workflow_dispatch'
uses: allenevans/[email protected]
with:
SERVER_IMAGE: ${{ github.event.inputs.server_image }}
LOCUST_USERS: ${{ github.event.inputs.users }}
LOCUST_SPAWN_RATE: ${{ github.event.inputs.spawn_rate }}
LOCUST_RUN_TIME: ${{ github.event.inputs.run_time }}
- name: Set environment variables (default)
if: github.event_name != 'workflow_dispatch' && github.event_name != 'repository_dispatch'
uses: allenevans/[email protected]
with:
SERVER_IMAGE: 'dswbot/wizard-server:develop'
LOCUST_USERS: '20'
LOCUST_SPAWN_RATE: '5'
LOCUST_RUN_TIME: '3m'
- name: Docker login [private]
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ secrets.PRIVATE_REGISTRY_URL }}
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }}
password: ${{ secrets.PRIVATE_REGISTRY_PASSWORD }}
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: pip
cache-dependency-path: |
requirements.txt
- name: Prepare Python env
run: |
python -m pip install -U pip setuptools wheel
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Prepare
run: |
make clean
make init
- name: Start DSW
run: |
make start
make wait
- name: Seed data
run: |
python tools/seeder.py "tests/${{ matrix.test }}"
- name: Run load test
run: |
locust -f tests/${{ matrix.test }}/locustfile.py \
--csv=${{ matrix.test }} \
--html=${{ matrix.test }}.html \
--headless \
--only-summary \
--host=http://localhost:3000 \
--users=$LOCUST_USERS \
--spawn-rate=$LOCUST_SPAWN_RATE \
--run-time=$LOCUST_RUN_TIME
- name: Convert results to JSON
run: |
python tools/csv2json.py ${{ matrix.test }}_stats.csv ${{ matrix.test }}.json
- name: Upload report artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.test }}-report
path: |
${{ matrix.test }}_*.csv
${{ matrix.test }}.html
${{ matrix.test }}.json
- name: Check results
shell: bash {0}
run: |
python tools/check_results.py $TEST_NAME.json tests/$TEST_NAME/expectations.json
if [ "$?" -gt "0" ]; then
echo "-----------------------------"
echo "Sending Slack notification..."
bash .github/scripts/slack-notify.sh "$WEBHOOK_URL" "$IMAGE" "$TEST_NAME" "$REPO" "$RUN" "$GH_EVENT"
exit 1
fi
env:
IMAGE: ${{ env.SERVER_IMAGE }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
REPO: ${{ github.repository }}
RUN: ${{ github.run_id }}
TEST_NAME: ${{ matrix.test }}
GH_EVENT: ${{ github.event_name }}