fix(supabase): db:trial second re-review fixes
Post-create scan covers pg_stat_statements and labels each count; log path defined; rotate-secrets 401 window documented; plan shows image state unknown without a daemon; start_containers checks the app host before recreating GoTrue; truthful restore and destroy way-out messages; harness checks read stdin from /dev/null. Harness 372/0.
This commit is contained in:
1 parent
d3bdbbe0ba
commit
f2cbf6814f
4 files changed
+121
-22
No files matched your search
@@ -46,7 +46,7 @@ trap cleanup EXIT
|
||||
PASS=0 FAIL=0
|
||||
pass() { echo "PASS $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo "FAIL $1"; FAIL=$((FAIL + 1)); }
|
||||
check() { local name="$1"; shift; if "$@"; then pass "$name"; else fail "$name"; fi; }
|
||||
check() { local name="$1"; shift; if "$@" </dev/null; then pass "$name"; else fail "$name"; fi; }
|
||||
|
||||
SEED_REL=supabase/seed/anatomical-sheets/equine/draft
|
||||
mkdir -p "$WORK/repo/scripts" "$WORK/repo/$SEED_REL/assets" "$WORK/repo/node_modules/.bin" \
|
||||
@@ -86,7 +86,8 @@ cat > "$WORK/bin/docker" <<'STUB'
|
||||
# SIGTERM while it archives), append-on-rm (the file named inside gets a byte when a container is
|
||||
# removed), term-on (an ERE: the first call whose argv line, or tag:<sql tag> for an exec, matches it
|
||||
# sends the script a SIGTERM), answers/measure-kib (the volumes' measured size), answers/<tag>.seq (one line per call).
|
||||
# answers/volume-ls (what `ls -A /volume` prints: a non-empty volume).
|
||||
# answers/volume-ls (what `ls -A /volume` prints: a non-empty volume; volume-ls-storage: for that volume only).
|
||||
# lost-after-archive: with fail/archive, the daemon is lost once the archive failed (as lost-now below).
|
||||
# Every failing `inspect -f` (an absent resource of any of the four kinds, a lost daemon) writes a
|
||||
# bare newline to stdout and the sentence to stderr, rc 1, as Docker 29.9.3 does (measured): the
|
||||
# script must judge stderr alone. Docker's own wording per kind:
|
||||
@@ -186,12 +187,19 @@ case "$sub" in
|
||||
if [ "$name" = faunosteo_trial_helper ] && [ -f "$st/fail/helper" ]; then exit 1; fi
|
||||
if [ "$input" -eq 1 ]; then [ ! -f "$st/fail/extract" ] || exit 1; save_stdin >/dev/null; fi
|
||||
# Measure: 100 KiB and 2 entries ("." and "./content"), what the archive below lists.
|
||||
if printf '%s\n' "$@" | grep -qx -- 'ls -A /volume'; then cat "$st/answers/volume-ls" 2>/dev/null || true; fi
|
||||
if printf '%s\n' "$@" | grep -qx -- 'ls -A /volume'; then
|
||||
vf="$st/answers/volume-ls"
|
||||
if [[ "$*" == *faunosteo_trial_storage:* && -f "$vf-storage" ]]; then vf="$vf-storage"; fi
|
||||
cat "$vf" 2>/dev/null || true
|
||||
fi
|
||||
if printf '%s\n' "$@" | grep -q -- 'du -sk /volume'; then
|
||||
printf '%s\n2\n' "$(cat "$st/answers/measure-kib" 2>/dev/null || echo 100)"
|
||||
fi
|
||||
if printf '%s\n' "$@" | grep -qx -- -cf; then
|
||||
[ ! -f "$st/fail/archive" ] || exit 3
|
||||
if [ -f "$st/fail/archive" ]; then
|
||||
if [ -f "$st/fail/lost-after-archive" ]; then : > "$st/lost-now"; fi
|
||||
exit 3
|
||||
fi
|
||||
if [ -f "$st/term-in-archive" ]; then bash "$STUB_TERM"; fi
|
||||
# A real (tiny) tar, so that the script's read-back has something to list. short-archive:
|
||||
# the root entry only, exit 0 (an archive cut at a member boundary).
|
||||
@@ -857,7 +865,7 @@ check "rotate-secrets: the final message does not claim sessions end" bash -c 'g
|
||||
check "rotate-secrets: every value renewed" bash -c 'for k in TR_PW TR_JWT_SECRET TR_ANON_KEY TR_SERVICE_KEY; do [ "$(grep "^$k=" "$1")" != "$(grep "^$k=" "$2")" ] || exit 1; done' _ "$STATE_DIR/secrets.env" "$CASE/secrets.before-rotation"
|
||||
check "rotate-secrets: a restorable, protected backup holding the previous secrets (no secrets.prev needed)" bash -c 'd=$(ls -d "$1"/*-pre-rotate* | tail -n 1); [ -n "$d" ] && [ "$(stat -c %a "$d")" = 700 ] && for f in db.tar storage.tar secrets.env stack.conf migrations.sha256 SHA256SUMS; do [ "$(stat -c %a "$d/$f")" = 600 ] || exit 1; done && cd "$d" && sha256sum --quiet -c SHA256SUMS && cmp -s secrets.env "$2"' _ "$STATE_DIR/backups" "$CASE/secrets.before-rotation"
|
||||
check "rotate-secrets: values reach psql by environment names only" log_has 'docker exec -i -e PGPASSWORD -e PGAPPNAME -e NEW_PW -e NEW_JWT -e ROT_DIGEST faunosteo_trial_db psql -X -q -h 127.0.0.1 -U supabase_admin'
|
||||
check "rotate-secrets: no rotation SQL text holds a secret, old or new" bash -c 'files=$(grep -lF -- "-- db-trial:rotate" $(find "$1" -type f)); [ -n "$files" ] && for f in $files; do grep -qF "set local log_min_error_statement = panic;" "$f" && grep -qF "app.trial_rotation" "$f" || exit 1; for s in "${@:2}"; do while IFS="=" read -r _ v; do [ -z "$v" ] || ! grep -qF -- "$v" "$f" || exit 1; done < "$s"; done; done' _ "$CASE/stub/stdin" "$STATE_DIR/secrets.env" "$CASE/secrets.before-rotation" "$CASE/secrets.before-lost" "$CASE/secrets.before-refusal"
|
||||
check "rotate-secrets: no rotation SQL text holds a secret, old or new" bash -c 'files=$(grep -lF -- "-- db-trial:rotate" /dev/null $(find "$1" -type f)); [ -n "$files" ] && for f in $files; do grep -qF "set local log_min_error_statement = panic;" "$f" && grep -qF "app.trial_rotation" "$f" || exit 1; for s in "${@:2}"; do while IFS="=" read -r _ v; do [ -z "$v" ] || ! grep -qF -- "$v" "$f" || exit 1; done < "$s"; done; done' _ "$CASE/stub/stdin" "$STATE_DIR/secrets.env" "$CASE/secrets.before-rotation" "$CASE/secrets.before-lost" "$CASE/secrets.before-refusal"
|
||||
check "rotate-secrets: six containers recreated, volumes kept" bash -c 'for n in db mail auth storage rest gateway; do grep -qx "docker rm faunosteo_trial_$n" "$1" && grep -q "^docker run -d --name faunosteo_trial_$n " "$1" || exit 1; done; ! grep -qF "docker volume rm" "$1"' _ "$CASE/log"
|
||||
check "rotate-secrets: no leftover secrets.next.env, no secrets.prev.env" bash -c '[ ! -e "$1/secrets.prev.env" ] && [ ! -e "$1/secrets.next.env" ]' _ "$STATE_DIR"
|
||||
check "rotate-secrets: new secrets absent from calls and output" secrets_absent "$STATE_DIR/secrets.env"
|
||||
@@ -1316,7 +1324,7 @@ rm -f "$CASE/stub/answers/txn-factors"
|
||||
fresh_stdin; fresh_log; trial_tty 'grant sheet_reviewer' grant Foo@Example.com sheet_reviewer
|
||||
check "grant Foo@Example.com: the lowercased address is used everywhere" bash -c '[ "$1" -eq 0 ] && grep -qF -- "-v email=foo@example.com" "$2" && ! grep -qF "Foo@" "$2" "$3"' _ "$RC" "$CASE/log" "$CASE/out"
|
||||
fresh_stdin; fresh_log; trial_typed "$PW"$'\n'"$PW" account Foo@Example.com
|
||||
check "account Foo@Example.com: the body carries the lowercased address" bash -c '[ "$1" -eq 0 ] && grep -qF "\"email\":\"foo@example.com\"" $(find "$2" -type f) && ! grep -qF "Foo@" "$3"' _ "$RC" "$CASE/stub/stdin" "$CASE/out"
|
||||
check "account Foo@Example.com: the body carries the lowercased address" bash -c '[ "$1" -eq 0 ] && grep -qF "\"email\":\"foo@example.com\"" /dev/null $(find "$2" -type f) && ! grep -qF "Foo@" "$3"' _ "$RC" "$CASE/stub/stdin" "$CASE/out"
|
||||
# 6: passwords count their blanks.
|
||||
fresh_log; trial_typed '12345678901'$'\n''12345678901' account long@trial.test
|
||||
check "account: an 11-character password is refused" bash -c '[ "$1" -ne 0 ] && grep -qF "12 characters" "$2" && ! grep -q "^curl .*admin/users" "$3"' _ "$RC" "$CASE/out" "$CASE/log"
|
||||
@@ -1574,6 +1582,42 @@ check "start with no usable app host: refused before any container is started or
|
||||
EXTRA=()
|
||||
|
||||
|
||||
echo "-- closure second re-review fixes (2026-11-11)"
|
||||
# m4: a plan without a daemon does not call the images "not pulled yet".
|
||||
new_case plan-down-images; : > "$CASE/stub/fail/daemon"; trial plan
|
||||
check "plan with the daemon down: each of the six images is unknown, none 'not pulled yet'" bash -c '[ "$(grep -cF "unknown (Docker daemon unreachable)" "$1")" -eq 6 ] && ! grep -qF "not pulled yet" "$1"' _ "$CASE/out"
|
||||
|
||||
# m6/m3: a refused inspect shows Docker's answer, quoted, and both hints.
|
||||
new_case inspect-shown; : > "$CASE/stub/fail/inspect-error"; trial create
|
||||
check "an inspect error: the quoted Docker answer, the docker info hint and the wording hint" bash -c '[ "$1" -ne 0 ] && grep -qF "(answer '"'"'Error response from daemon: permission denied'"'"')" "$2" && grep -qF "(docker info)" "$2" && grep -qF "measured on Docker 29.9.3" "$2"' _ "$RC" "$CASE/out"
|
||||
|
||||
# m6/m10: the destroy way out when the listing fails, and when a container still runs.
|
||||
new_case way-listing; trial create
|
||||
: > "$CASE/stub/fail/archive"; : > "$CASE/stub/fail/lost-after-archive"
|
||||
fresh_log; trial_tty faunosteo_trial destroy
|
||||
check "destroy way out with the daemon lost after the failed archive: each kind prints its listing-failed line" bash -c '[ "$1" -ne 0 ] && for k in container network volume; do grep -qF "($k listing failed, Docker did not answer: inspect the faunosteo_trial ${k}s by hand)" "$2" || exit 1; done' _ "$RC" "$CASE/out"
|
||||
new_case way-still-runs; trial create
|
||||
: > "$CASE/stub/fail/stop-noop"; fresh_log; trial_tty faunosteo_trial destroy
|
||||
check "destroy whose backup fails on a container that still runs: docker stop named before docker rm" bash -c '[ "$1" -ne 0 ] && grep -qF "still runs after the stop" "$2" && s=$(grep -nF " docker stop faunosteo_trial_db" "$2" | head -n 1 | cut -d: -f1) && r=$(grep -nF " docker rm faunosteo_trial_db" "$2" | head -n 1 | cut -d: -f1) && [ -n "$s" ] && [ -n "$r" ] && [ "$s" -lt "$r" ]' _ "$RC" "$CASE/out"
|
||||
check "destroy whose backup fails on a container that still runs: nothing removed" no_removal
|
||||
new_case way-stopped; trial create
|
||||
echo 999999999999 > "$CASE/stub/answers/measure-kib"; fresh_log; trial_tty faunosteo_trial destroy
|
||||
check "destroy way out with every container stopped: no docker stop line" bash -c '[ "$1" -ne 0 ] && grep -qF "no backup could be made" "$2" && ! grep -qF "docker stop faunosteo" "$2"' _ "$RC" "$CASE/out"
|
||||
|
||||
# m5: GoTrue's recreation reads the app host; backup's restart refuses before the first start.
|
||||
new_case restart-host; trial create
|
||||
rm -f "$CASE/stub/containers/faunosteo_trial_auth" "$CASE/stub/ports/faunosteo_trial_auth"
|
||||
EXTRA=(FAUNOSTEO_TRIAL_HOST=8.8.8.8); fresh_log; trial backup
|
||||
check "backup with GoTrue missing and no usable app host: the restart refuses before any container starts" bash -c '[ "$1" -ne 0 ] && grep -qF "must be loopback or a private address" "$2" && ! grep -qE "^docker (start|run -d|restart) " "$3"' _ "$RC" "$CASE/out" "$CASE/log"
|
||||
EXTRA=()
|
||||
|
||||
# m9: a restore whose second volume fails says the first was extracted.
|
||||
b2_stack restore-second
|
||||
echo lost+found > "$CASE/stub/answers/volume-ls-storage"
|
||||
fresh_log; trial_tty "restore $RN" restore "$RN"
|
||||
check "restore: the storage volume not empty after the database volume was extracted says so" bash -c '[ "$1" -ne 0 ] && grep -qF "faunosteo_trial_storage is not empty after its creation: faunosteo_trial_db was extracted, faunosteo_trial_storage was not" "$2" && ! grep -qF "nothing was extracted" "$2"' _ "$RC" "$CASE/out"
|
||||
|
||||
|
||||
echo "-- db:sandbox state guard"
|
||||
new_case sandbox-guard; mkdir -p "$CASE/trialstate"; : > "$CASE/trialstate/.faunosteo-trial-state"
|
||||
EXTRA=(FAUNOSTEO_SANDBOX_DIR="$CASE/trialstate"); sandbox down
|
||||
|
||||
Reference in new issue
Block a user