diff --git a/scripts/compose-smoke.sh b/scripts/compose-smoke.sh index b1f0f43..f1dc441 100755 --- a/scripts/compose-smoke.sh +++ b/scripts/compose-smoke.sh @@ -310,8 +310,25 @@ printf ' info policy reload failures counted after the table went away: %s\n' " check 'the state counts a policy pillar that cannot read its table' 'yes' \ "$([ "${POLICY_FAILS:-0}" != "0" ] && echo yes || echo no)" check 'readiness stops saying ready while it cannot' '503' "$(code "$EDGE/readyz")" +# Sampled with a retry, not once. The first Linux rehearsal of this gate failed +# here on a single sample: /state had just reported one reload failure, and the +# very next GET /policy answered with the header at 0 — a reload that succeeded +# in between (a pooled sqlite connection can serve the schema it already +# prepared, which is the same reason chmod 000 on the file never breaks the +# edge). The product was not lying: the header said what the last read did. The +# gate was asserting on one instant. So the header is polled while the table is +# gone, and what was actually seen is printed either way. +POLICY_HDR="" +for _ in $(seq 1 6); do + POLICY_HDR=$(hdr -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$EDGE/admin-api/policy" \ + | grep -i '^x-policy-reload-failures:' | tr -d '\r') + printf '%s' "$POLICY_HDR" | grep -qi ': [1-9]' && break + code "$EDGE/no-such-page" >/dev/null + sleep 2 +done +printf ' info policy provenance header while the table is gone: %s\n' "${POLICY_HDR:-none}" check 'the policy answer carries its own provenance' 'yes' \ - "$(hdr -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$EDGE/admin-api/policy" | grep -qi '^x-policy-reload-failures: [1-9]' && echo yes || echo no)" + "$(printf '%s' "$POLICY_HDR" | grep -qi '^x-policy-reload-failures: [1-9]' && echo yes || echo no)" # The two pillars are counted separately on purpose: here the snapshot is still # refreshing fine and only the policy read is broken, and a single blended # "storage is unhappy" flag would lose exactly that.