diff --git a/.github/workflows/load-tests.yml b/.github/workflows/load-tests.yml index 77ca28ca..d556f78f 100644 --- a/.github/workflows/load-tests.yml +++ b/.github/workflows/load-tests.yml @@ -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