fix(14.2): WR-08 go.log scan fails closed without request records
With SUMMER_HTTP__ACCESS_LOG off the Go log has no http request records, and the 5xx scan passed on an empty signal. scan_go_log now also refuses unless the part of go.log written during this --e2e run (after the offset taken once the stack is up) has an http request record. Self-test cases: no records, an empty log, records only before the offset.
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
# Playwright specs through dev-stack.sh e2e (any skip,
|
||||
# unexpected, flaky or zero expected fails), the D-15
|
||||
# report-only specs (counts printed, never blocking) and the
|
||||
# Go log scan (search engine failure or a 5xx record fails)
|
||||
# Go log scan (search engine failure or a 5xx record fails,
|
||||
# and so does a run that wrote no http request record)
|
||||
# --all every stage in that order; the last line is
|
||||
# "Phase 14.2 gate passed"
|
||||
#
|
||||
@@ -186,15 +187,23 @@ run_regex() {
|
||||
printf '^(%s)$' "$*"
|
||||
}
|
||||
|
||||
# scan_go_log FILE refuses a silent search fallback or a 5xx request record
|
||||
# (research G8, D-12). A 499 (the surf access log's status for a 5xx caused
|
||||
# by the client going away) is not a 5xx; a 5xx with client_gone=true is.
|
||||
# scan_go_log FILE [OFFSET] refuses a silent search fallback or a 5xx
|
||||
# request record anywhere in FILE (research G8, D-12). A 499 (the surf
|
||||
# access log's status for a 5xx caused by the client going away) is not a
|
||||
# 5xx; a 5xx with client_gone=true is. It also refuses unless the part of
|
||||
# FILE after OFFSET bytes (the output of this run; default the whole file)
|
||||
# has an "http request" record: with the access log off a clean scan would
|
||||
# prove nothing (WR-08).
|
||||
scan_go_log() {
|
||||
local file="$1" hits
|
||||
local file="$1" offset="${2:-0}" hits
|
||||
[[ -f "$file" ]] || {
|
||||
echo "refuse: Go log $file not found" >&2
|
||||
return 1
|
||||
}
|
||||
if ! tail -c "+$((offset + 1))" "$file" | grep -q 'msg="http request"'; then
|
||||
echo "refuse: $file has no http request record from this run; set SUMMER_HTTP__ACCESS_LOG=true in the env file" >&2
|
||||
return 1
|
||||
fi
|
||||
hits="$(grep -nE 'album search engine failed|status=5[0-9][0-9]([^0-9]|$)' "$file" || true)"
|
||||
if [[ -n "$hits" ]]; then
|
||||
printf '%s\n' "$hits" | tail -n 20 >&2
|
||||
@@ -340,11 +349,19 @@ run_self_test() {
|
||||
printf '%s\n' '[go] level=INFO msg="http request" method=GET pattern="GET /a" status=503 duration_ms=1' >"$dir/5xx.log"
|
||||
printf '%s\n' '[go] level=INFO msg="http request" method=GET pattern="GET /a" status=500 duration_ms=1 client_gone=true' >"$dir/5xx-gone.log"
|
||||
printf '%s\n' '[go] level=WARN msg="album search engine failed" err=timeout' >"$dir/search.log"
|
||||
printf '%s\n' '[go] level=INFO msg="serve: listening" addr=127.0.0.1:8423' >"$dir/no-records.log"
|
||||
expect_status go-log-clean 0 scan_go_log "$dir/clean.log"
|
||||
expect_status go-log-5xx 1 scan_go_log "$dir/5xx.log"
|
||||
expect_status go-log-5xx-client-gone 1 scan_go_log "$dir/5xx-gone.log"
|
||||
expect_status go-log-search 1 scan_go_log "$dir/search.log"
|
||||
expect_status go-log-missing 1 scan_go_log "$dir/absent.log"
|
||||
expect_status go-log-no-records 1 scan_go_log "$dir/no-records.log"
|
||||
expect_status go-log-empty 1 scan_go_log /dev/null
|
||||
# Request records only before this run's offset: the run logged none.
|
||||
cat "$dir/clean.log" "$dir/no-records.log" >"$dir/old-records.log"
|
||||
expect_status go-log-old-records 1 scan_go_log "$dir/old-records.log" "$(stat -c '%s' "$dir/clean.log")"
|
||||
cat "$dir/no-records.log" "$dir/clean.log" >"$dir/new-records.log"
|
||||
expect_status go-log-new-records 0 scan_go_log "$dir/new-records.log" "$(stat -c '%s' "$dir/no-records.log")"
|
||||
printf '# tests 9\n# pass 9\n# fail 0\n# cancelled 0\n# skipped 0\n# todo 0\n' >"$dir/tap-clean"
|
||||
printf '# tests 9\n# pass 8\n# fail 1\n# cancelled 0\n# skipped 0\n# todo 0\n' >"$dir/tap-fail"
|
||||
printf '# tests 9\n# pass 8\n# fail 0\n# cancelled 0\n# skipped 1\n# todo 0\n' >"$dir/tap-skip"
|
||||
@@ -571,12 +588,14 @@ run_e2e() {
|
||||
bash "$DEV_STACK" up --detach
|
||||
bash "$DEV_STACK" fresh
|
||||
seed_out_private
|
||||
local log_start=0
|
||||
[[ ! -f "$GO_LOG" ]] || log_start="$(stat -c '%s' "$GO_LOG")"
|
||||
bash "$DEV_STACK" guard
|
||||
bash "$DEV_STACK" e2e "${GATE_SPECS[@]}"
|
||||
echo "e2e (report only, D-15): ${REPORT_SPECS[*]}"
|
||||
bash "$DEV_STACK" e2e --report-only "${REPORT_SPECS[@]}" 2>&1 | sed 's/^/e2e (report only) /' || rc=$?
|
||||
((rc == 0)) || echo "e2e (report only) run exited $rc (not blocking)"
|
||||
scan_go_log "$GO_LOG"
|
||||
scan_go_log "$GO_LOG" "$log_start"
|
||||
echo "phase14.2 e2e passed"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user