diff --git a/scripts/compose-smoke.sh b/scripts/compose-smoke.sh index 67c1d0d..56e187f 100755 --- a/scripts/compose-smoke.sh +++ b/scripts/compose-smoke.sh @@ -817,13 +817,39 @@ check 'the scanner really was one source the edge tracked' 'yes' \ "$(printf '%s' "$STREAKS_JSON" | streaks_where "b['sourceKey']=='$BAN_SRC'" | awk '{exit ($1+0>=1)?0:1}' && echo yes || echo no)" check 'and no engine ban for it reached storage' 'yes' \ "$(admin "$EDGE/admin-api/blocks?source=engine" | jcount "b['sourceKey']=='$BAN_SRC'" | awk '{exit ($1+0==0)?0:1}' && echo yes || echo no)" +# The ban pillar is not updated on the request path: the write attempt and the +# failure to record it land a moment after the refusal that triggered them. Read +# immediately after the fifth refusal, this scene used to see the counters at 0 +# and /readyz at 200 while the same run's log already carried two lines saying +# the ban was not persisted (75ee822: /tmp/c25_compose2.log 180/4 and +# /tmp/c25_compose3.log 179/5 — three of the four failures were this read). The +# state is therefore polled, and the raw values are printed as a trajectory: +# "the counter is 0" and "the field is not in the answer" used to be the same +# word in the log, which is where a real regression would hide (OPEN-42). +PILLAR_OK=0; PILLAR_WAIT=0; PILLAR_TRAIL=''; PILLAR_READY=''; PILLAR_WHY='' +BAN_FAILS=0; NOT_WRITTEN=0 +for _ in $(seq 1 10); do + STATE_JSON=$(admin "$EDGE/admin-api/state") + BAN_FAILS=$(printf '%s' "$STATE_JSON" | jval banWriteFailures) + NOT_WRITTEN=$(printf '%s' "$STATE_JSON" | jval bansNotWritten) + PILLAR_WHY=$(printf '%s' "$STATE_JSON" | jval banLastWriteError) + PILLAR_READY=$(code "$EDGE/readyz") + PILLAR_TRAIL="$PILLAR_TRAIL ${BAN_FAILS:-?}/${NOT_WRITTEN:-?}" + if [ -n "${BAN_FAILS:-}" ] && [ "${BAN_FAILS:-0}" -ge 1 ] && [ "$PILLAR_READY" = "503" ]; then + PILLAR_OK=1; break + fi + PILLAR_WAIT=$((PILLAR_WAIT+2)); sleep 2 +done +printf ' info ban pillar after %s s of waiting — failures/notWritten:%s\n' "$PILLAR_WAIT" "$PILLAR_TRAIL" +printf ' info readyz at that moment: %s; the reason quoted: %s\n' "${PILLAR_READY:-none}" "${PILLAR_WHY:-(none)}" +check 'the ban pillar reached its failure state within the wait budget' '1' "$PILLAR_OK" check 'the state counts the ban write that failed' 'yes' \ - "$(admin "$EDGE/admin-api/state" | jval banWriteFailures | awk '{exit ($1+0>=1)?0:1}' && echo yes || echo no)" + "$([ "${BAN_FAILS:-0}" -ge 1 ] && echo yes || echo no)" check 'and says how many bans were never written' 'yes' \ - "$(admin "$EDGE/admin-api/state" | jval bansNotWritten | awk '{exit ($1+0>=1)?0:1}' && echo yes || echo no)" -check 'readiness names the ban writes, because this is the enforcement path' '503' "$(code "$EDGE/readyz")" + "$([ "${NOT_WRITTEN:-0}" -ge 1 ] && echo yes || echo no)" +check 'readiness names the ban writes, because this is the enforcement path' '503' "$PILLAR_READY" check 'the reason it quotes is the storage error, not a concurrency race' 'yes' \ - "$(admin "$EDGE/admin-api/state" | jval banLastWriteError | grep -qi 'ban write blocked' && echo yes || echo no)" + "$(printf '%s' "$PILLAR_WHY" | grep -qi 'ban write blocked' && echo yes || echo no)" # Counted after the wait, so both numbers describe the same moment: the scene # has demonstrably produced its log lines, and none of them is the race sentence. BAN_LOG_LINES=$(log_wait_for 'could not persist a ban for')