Skip to content

[MEX-723] Implement load test with filteredTokesn #2

[MEX-723] Implement load test with filteredTokesn

[MEX-723] Implement load test with filteredTokesn #2

Workflow file for this run

name: Load Tests
on:
pull_request:
branches: [main, development]
jobs:
test-base:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
timescaledb:
image: timescale/timescaledb-ha:pg16
env:
POSTGRES_USER: timescaledb
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:latest
env:
MONGO_INITDB_ROOT_USERNAME: mongodb
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.sha }}
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Copy config
run: npm run copy-env
- name: Create Migrations
run: npm run typeorm:create-migration
- name: Generate Migrations
run: npm run typeorm:generate-migration
- name: Run Migrations
run: npm run typeorm:run-migrations
- name: Build
run: npm run build
- name: Start Node.js API
run: GH_ACTIONS=true node ./dist/main.js &
- name: Install k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Wait for API to be ready
run: |
until curl --output /dev/null --silent --max-time 60 http://localhost:3005/graphql; do
echo 'Waiting for API...'
sleep 5
done
- name: Preload cache
run: k6 run ./k6/preload.js
- name: Run k6 Load Test
run: k6 run ./k6/script.js
- name: Upload result file for base branch
uses: actions/upload-artifact@v4
with:
name: base-results
path: k6/output/summary.json
test-head:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
timescaledb:
image: timescale/timescaledb-ha:pg16
env:
POSTGRES_USER: timescaledb
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:latest
env:
MONGO_INITDB_ROOT_USERNAME: mongodb
MONGO_INITDB_ROOT_PASSWORD: password
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Copy config
run: npm run copy-env
- name: Create Migrations
run: npm run typeorm:create-migration
- name: Generate Migrations
run: npm run typeorm:generate-migration
- name: Run Migrations
run: npm run typeorm:run-migrations
- name: Build
run: npm run build
- name: Start Node.js API
run: GH_ACTIONS=true node ./dist/main.js &
- name: Install k6
run: |
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6
- name: Wait for API to be ready
run: |
until curl --output /dev/null --silent --max-time 60 http://localhost:3005/graphql; do
echo 'Waiting for API...'
sleep 5
done
- name: Preload cache
run: k6 run ./k6/preload.js
- name: Run k6 Load Test
run: k6 run ./k6/script.js
- name: Upload result file for head branch
uses: actions/upload-artifact@v4
with:
name: head-results
path: k6/output/summary.json
compare-results:
runs-on: ubuntu-latest
needs: [test-base, test-head]
steps:
- uses: actions/checkout@v2
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Compare test results
run: |
node ./k6/compare-results.js ${{ github.event.pull_request.base.sha }} artifacts/base-results/summary.json ${{ github.event.pull_request.head.sha }} artifacts/head-results/summary.json report.md
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: k6 load testing comparison
- name: Display Report Contents
run: |
echo "=== Load Test Comparison Report ==="
cat report.md
echo "================================"
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-file: report.md
edit-mode: replace