-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (106 loc) · 3.48 KB
/
load-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Load Tests
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
determine-service-matrix:
runs-on: ubuntu-latest
outputs:
services: ${{ steps.determine-matrix.outputs.changes }}
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: determine-matrix
with:
# Note, 'common' is for future use--when code is factored out into common libraries,
# but it's set up here so that the workflow logic could be tested with it present
filters: |
common:
- '*'
- '.github/**'
account:
- '*'
- '.github/**'
- 'services/account/**'
graph:
- '*'
- '.github/**'
- 'services/graph/**'
content-publishing:
- '*'
- '.github/**'
- 'services/content-publishing/**'
content-watcher:
- '*'
- '.github/**'
- 'services/content-watcher/**'
build:
name: '[${{ matrix.service }}] Load Test'
runs-on: ubuntu-latest
needs: determine-service-matrix
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.determine-service-matrix.outputs.services) }}
exclude:
- service: common
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
cache-dependency-path: tools/ci-k6/package-lock.json
- name: Install dependencies
working-directory: tools/ci-k6
run: npm ci
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_TOKEN}}
- name: Start Frequency
run: |
docker compose -f docker-compose.yaml -f docker-compose-k6.${{ matrix.service }}.yaml up -d frequency
sleep 20
- name: Generate Provider and Capacity
working-directory: tools/ci-k6
run: npm run main
# Just start the services we need...
- name: Start All Services
run: docker compose -f docker-compose.yaml -f docker-compose-k6.${{ matrix.service }}.yaml up -d
- name: Wait for API to be ready
uses: actions/github-script@v7
with:
script: |
const start = Date.now();
while (Date.now() - start < 120000) {
try {
if ((await fetch('http://localhost:3000/readyz')).status === 200) {
console.log('Ready check passed');
return;
}
} catch (e) {}
await new Promise(r => setTimeout(r, 3000));
}
console.log('Timeout reached. Ready check failed.');
process.exit(1);
- name: Setup K6
uses: grafana/setup-k6-action@v1
- name: Run k6 Tests
run: |
for test_file in services/${{ matrix.service }}/k6-test/*.js; do
k6 run --no-usage-report "$test_file" || exit 1
done
- name: Stop Docker Compose
if: always()
run: docker compose -f docker-compose.yaml -f docker-compose-k6.${{ matrix.service }}.yaml down