The log assertion sampled one instant, and the log line had not landed yet
The compose gate passed 74/0 on the macOS host and failed "and the log says what actually happened" on the first Linux rehearsal of the same tree. The wording was not the problem and neither was the platform: the grep over `docker compose logs edge` was run immediately after the burst that produced the line. Measured on the shipped image with the stack still up — the grep right after the five refusals answered 0, the same grep two seconds later answered 3. The /state field is updated synchronously on the request path; the line reaches the daemon's log store a moment later, so the state assertions passed and the log assertion failed on timing. Both log assertions now poll, and both print the count they saw, so a passing log assertion shows the number rather than an absence. The race-line count is taken after the wait, so the before/after pair describes one moment: this scene demonstrably produced 3 lines saying the ban was not persisted, and 0 lines calling it a concurrency race. Linux rehearsal at this tree: 74 passed, 0 failed (was 73/1).
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user