From 393e09c16ff52f0fbc934765c137db2dd91d2930 Mon Sep 17 00:00:00 2001 From: Carsten Milling Date: Sun, 18 Oct 2026 15:56:01 +0200 Subject: [PATCH] Wait until the test corpus is loaded before testing The loadtest container waited for `"plays":[{`, which never matches the indented JSON of the API, so it always gave up after 60 s while the corpus was still loading, and nothing checked its exit code: `docker compose up --wait` doesn't wait for it to finish. The tests therefore always started while the corpus was loading, which went unnoticed as long as loading finished early in the first test run. When loading didn't finish at all, as in a run on the Ubuntu 26.04 runner, this only showed minutes later as an error in the DTS validator. The container now waits up to 5 minutes for the commit of the corpus, which the load job records after loading all plays, and the workflow fails right after starting the stack, with the logs of loadtest and api, if loading doesn't succeed. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/schemathesis.yml | 8 ++++++++ compose.t.yml | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/schemathesis.yml b/.github/workflows/schemathesis.yml index 8f67cdee..7ad7ca33 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 8f38f78b..07887e18 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