Corrige la bascule du catalogue, detecte un changement de depot, compte les packs a l'import
build / Images Harbor (catalog-sync, Dockerfile.catalog-sync) (push) Successful in 9m45s
build / Garde-fou (push) Successful in 10m18s
build / Images Harbor (web, Dockerfile) (push) Successful in 13m10s

This commit is contained in:
hcornet committed 2026-09-11 12:16:57 +02:00
1 parent 469305b4a7
commit c411f2933d
5 files changed
+116 -5

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
#!/bin/sh
# Verifie la synchronisation du catalogue sur un vrai depot Git local.
#
# Le defaut corrige le 11/09/2026 ne se voyait qu'a la deuxieme revision : la
# premiere bascule creait le lien, la seconde le suivait au lieu de le
# remplacer, et le catalogue restait fige pendant que le script annoncait des
# publications reussies. Ce test joue donc deux revisions.
#
# sh tests/sync.sh
set -eu
TRAVAIL=$(mktemp -d /tmp/enclume-sync-XXXXXX)
trap 'rm -rf "$TRAVAIL"' EXIT
DEPOT="$TRAVAIL/depot"
DESTINATION="$TRAVAIL/catalogue"
mkdir -p "$DEPOT/catalog/system" "$DESTINATION"
cd "$DEPOT"
git init --quiet --initial-branch=main
git config user.email "[email protected]"
git config user.name "Essai"
echo "premier: pack" > catalog/system/premier.yml
git add -A && git commit --quiet -m "premiere revision"
cd - > /dev/null
lancer_un_cycle() {
CATALOG_REPO="$DEPOT" CATALOG_DEST="$DESTINATION" CATALOG_BRANCH=main \
CATALOG_SUBDIR=catalog SYNC_INTERVAL=1 RELOAD_URL="" \
CATALOG_TRAVAIL="$TRAVAIL/clone" \
timeout 20 sh docker/catalog-sync.sh > "$TRAVAIL/journal" 2>&1 || true
}
echouer() {
echo "ECHEC : $1"
echo "--- journal ---"
cat "$TRAVAIL/journal" 2>/dev/null || true
echo "--- arborescence ---"
ls -la "$DESTINATION"
exit 1
}
# Premiere revision
lancer_un_cycle
[ -L "$DESTINATION/actuel" ] || echouer "actuel n'est pas un lien symbolique"
[ -f "$DESTINATION/actuel/system/premier.yml" ] || echouer "le premier pack n'est pas publie"
# Seconde revision : c'est ici que le defaut se manifestait
cd "$DEPOT"
echo "second: pack" > catalog/system/second.yml
git add -A && git commit --quiet -m "seconde revision"
ATTENDU=$(git rev-parse --short HEAD)
cd - > /dev/null
lancer_un_cycle
OBTENU=$(basename "$(readlink "$DESTINATION/actuel")")
[ "$OBTENU" = "rev-$ATTENDU" ] || echouer "actuel pointe sur $OBTENU au lieu de rev-$ATTENDU"
[ -f "$DESTINATION/actuel/system/second.yml" ] || echouer "le second pack n'est pas publie"
[ -e "$DESTINATION/actuel/actuel.neuf" ] && echouer "un lien parasite a ete depose dans la revision"
echo "synchronisation : bascule correcte sur deux revisions successives"