diff --git a/tests/proof/cases/04_query_correctness.sh b/tests/proof/cases/04_query_correctness.sh index 3d5d4ba..39e8169 100755 --- a/tests/proof/cases/04_query_correctness.sh +++ b/tests/proof/cases/04_query_correctness.sh @@ -26,6 +26,15 @@ substitute_table() { sed "s/FROM workers/FROM ${DATASET}/g; s/from workers/from ${DATASET}/g" } +# Wait for queryd to have the view from 03's ingest. queryd refreshes +# every 500ms (proof override of the 30s prod default); on cache-warm +# runs cases fire faster than the next tick. Up to 5s budget. +if ! proof_wait_for_sql 5 "SELECT 1 FROM ${DATASET} LIMIT 0"; then + proof_skip "$CASE_ID" "queryd view ${DATASET} never appeared in 5s" \ + "queryd refresh ticker may be stalled or 03_ingest registration failed" + return 0 2>/dev/null || exit 0 +fi + # Iterate the 5 queries. n=$(jq '.queries | length' "$EXPECTED_FILE") for i in $(seq 0 $((n-1))); do diff --git a/tests/proof/lib/http.sh b/tests/proof/lib/http.sh index f3def3e..5326241 100644 --- a/tests/proof/lib/http.sh +++ b/tests/proof/lib/http.sh @@ -108,6 +108,32 @@ proof_call() { _proof_http_run "$case_id" "$probe" "$method" "$url" "$@" } +# proof_wait_for_sql: wait for a SQL probe to return 200, up to budget +# seconds. Use when a case follows an ingest and queryd's view-refresh +# (default 500ms tick) may not have fired yet. NOT a retry — a wait +# for a known eventual-consistency event. No evidence emitted (this +# is test setup, not a claim). +# +# proof_wait_for_sql +# +# Returns 0 if the probe succeeded; 1 on timeout. +proof_wait_for_sql() { + local budget="${1:-10}" sql="$2" + local deadline=$(($(date +%s) + budget)) + local body + body=$(jq -nc --arg s "$sql" '{sql:$s}') + while [ "$(date +%s)" -lt "$deadline" ]; do + if curl -sf --max-time 1 -X POST \ + -H 'Content-Type: application/json' \ + -d "$body" \ + "${PROOF_GATEWAY_URL}/v1/sql" >/dev/null 2>&1; then + return 0 + fi + sleep 0.1 + done + return 1 +} + # Helper accessors — reads the per-probe JSON. proof_status_of() { local case_id="$1" probe="$2"