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