Skip to content

Commit

Permalink
Wait for the API to be ready before running the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwade committed Aug 5, 2024
1 parent 7a3cee2 commit 970c778
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,27 @@ jobs:
- 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: |
echo "Waiting 20 seconds for everything to be loaded up..."
sleep 20;
for test_file in services/${{ matrix.service }}/k6-test/*.js; do
k6 run --no-usage-report "$test_file" || exit 1
done
Expand Down

0 comments on commit 970c778

Please sign in to comment.