From c1604b9a041ca55eb498e50d0fd40649a559ad63 Mon Sep 17 00:00:00 2001 From: Evan Jarrett Date: Thu, 13 Aug 2026 20:55:38 -0500 Subject: [PATCH] test/e2e: key DB snapshots on the migration set, not the highest version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Batching reorders migrations. val/04-oauth carries e75b2e2 (commit 48 of the range), whose migration is 0031, while 0028-0030 only arrive in batches 09, 12 and 14. So val/04 holds {..0027, 0031} and val/09 holds {..0027, 0028, 0031}. Both have a max version of 0031, so keying the snapshot on the max would restore val/04's database onto val/09 — a database missing 0028's schema while schema_migrations claims otherwise. Snapshots are now keyed on a fingerprint of every migration file present, which distinguishes those two states. The max version is kept in the filename purely so the directory stays readable. Co-Authored-By: Claude Opus 5 (1M context) --- test/e2e/val-switch.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/e2e/val-switch.sh b/test/e2e/val-switch.sh index 1e48422..3b41a25 100755 --- a/test/e2e/val-switch.sh +++ b/test/e2e/val-switch.sh @@ -63,11 +63,19 @@ fi # a naive wipe-per-switch costs an interactive `docker-credential-atcr login` on # every batch. Restoring a snapshot keeps the session alive across every batch # that shares a level. -LEVEL=$(ls pkg/appview/db/migrations/*.yaml 2>/dev/null \ - | sed -E 's|.*/([0-9]{4})_.*|\1|' | sort -n | tail -1) +# Key the snapshot on the FULL SET of migrations present, not the highest one. +# Batching reorders migrations: val/04 carries e75b2e2, whose migration is 0031, +# while 0028-0030 arrive later in batches 09, 12 and 14. So val/04 holds +# {..0027, 0031} and val/09 holds {..0027, 0028, 0031} — both have a max of +# 0031, and keying on the max would restore val/04's snapshot onto val/09, which +# needs 0028's schema. The fingerprint distinguishes them. +MIGS=$(ls pkg/appview/db/migrations/*.yaml 2>/dev/null \ + | sed -E 's|.*/([0-9]{4})_.*|\1|' | sort -n) +LEVEL=$(printf '%s\n' "$MIGS" | tail -1) LEVEL=${LEVEL:-0000} -SNAP="$SNAPDIR/ui.level-${LEVEL}.db" -echo "==> branch migration level: ${LEVEL}" +FINGERPRINT=$(printf '%s\n' "$MIGS" | md5sum | cut -c1-8) +SNAP="$SNAPDIR/ui.level-${LEVEL}-${FINGERPRINT}.db" +echo "==> branch migrations: max ${LEVEL}, set ${FINGERPRINT} ($(printf '%s\n' "$MIGS" | wc -l) files)" echo "==> tearing down appview" docker compose rm -sf atcr-appview