diff --git a/scripts/compose-smoke.sh b/scripts/compose-smoke.sh index 4c0d1a3..2a8dcfd 100755 --- a/scripts/compose-smoke.sh +++ b/scripts/compose-smoke.sh @@ -61,6 +61,21 @@ streaks_fetch() { sleep 2 done } +# Lines reach the daemon's log store a moment after the /state field they belong +# to is updated — measured on the shipped image: the grep run immediately after +# the burst answered 0 and the same grep two seconds later answered 3. So the +# log assertions poll, and print the count they saw, instead of sampling one +# instant and calling it a contract. +log_count() { docker compose logs edge 2>/dev/null | grep -ci "$1" || true; } +log_wait_for() { + n=0 + for _ in $(seq 1 10); do + n=$(log_count "$1") + [ "${n:-0}" != 0 ] && break + sleep 2 + done + printf '%s' "${n:-0}" +} streaks_info() { printf ' info the live streak map: %s tracked, %s standing\n' \ "$(printf '%s' "$STREAKS_JSON" | jval trackedSources)" \ @@ -509,11 +524,15 @@ check 'and says how many bans were never written' 'yes' \ check 'readiness names the ban writes, because this is the enforcement path' '503' "$(code "$EDGE/readyz")" 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)" -RACES_AFTER=$(docker compose logs edge 2>/dev/null | grep -c 'concurrent ban on') +# 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') +RACES_AFTER=$(log_count 'concurrent ban on') printf ' info lines calling a ban write a race, before/after this scene: %s/%s\n' "$RACES_BEFORE" "$RACES_AFTER" +printf ' info lines saying the ban was not persisted and nothing is enforcing it: %s\n' "$BAN_LOG_LINES" check 'the log no longer calls a storage failure a race' "$RACES_BEFORE" "$RACES_AFTER" check 'and the log says what actually happened' 'yes' \ - "$(docker compose logs edge 2>/dev/null | grep -qi 'could not persist a ban for' && echo yes || echo no)" + "$([ "${BAN_LOG_LINES:-0}" -ge 1 ] && echo yes || echo no)" sidecar <<'PYSQL' import sqlite3 c = sqlite3.connect("/app/data/openwaf.db", isolation_level=None)