diff --git a/.github/workflows/schemathesis.yml b/.github/workflows/schemathesis.yml index 8f67cde..7ad7ca3 100644 --- a/.github/workflows/schemathesis.yml +++ b/.github/workflows/schemathesis.yml @@ -38,6 +38,14 @@ jobs: - run: docker --version - name: Start the docker-compose stack run: docker compose up --detach --wait + # `up --wait` doesn't wait for the loadtest container to finish + - name: Wait for the test corpus to be loaded + run: | + status=$(docker wait "$(docker compose ps --all --quiet loadtest)") + if [ "$status" != 0 ]; then + docker compose logs loadtest api + exit 1 + fi - name: Test if /info returns a response run: curl --verbose http://localhost:8081/exist/restxq/v1/info - name: Test if corpus returns a response diff --git a/compose.t.yml b/compose.t.yml index 8f38f78..07887e1 100644 --- a/compose.t.yml +++ b/compose.t.yml @@ -44,13 +44,17 @@ services: -H 'Content-Type: application/json' \ -d '{"load": true}' \ http://api:8080/exist/restxq/v1/corpora/test - echo "Waiting for corpus contents to be available..." + # The load job records the commit of the corpus after loading all + # of its plays. (Every play has a commit, too, so check the corpus + # list, which has no plays.) Check only every 5 s for up to 5 + # minutes, as loading keeps the database busy. + echo "Waiting for the corpus to be loaded..." for i in $$(seq 1 60); do - if curl -sf http://api:8080/exist/restxq/v1/corpora/test | grep -q '"plays":\[{'; then + if curl -sf http://api:8080/exist/restxq/v1/corpora | grep -q '"commit"'; then echo "Test corpus loaded." exit 0 fi - sleep 1 + sleep 5 done echo "Timed out waiting for test corpus to load." >&2 exit 1