From 8dc7721efe08c6b1c9b45c23eb161bbbe27d0753 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Mon, 12 Oct 2026 21:21:41 +0200 Subject: [PATCH] =?UTF-8?q?f-55:=20lab:=20two=20utilise=20labctl=200.1.0rc?= =?UTF-8?q?001,=20t=C3=A9l=C3=A9charg=C3=A9=20et=20v=C3=A9rifi=C3=A9=20par?= =?UTF-8?q?=20test/e2e/labctl.sh=20#55?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: GnomeZworc --- test/e2e/labctl.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/e2e/run.sh | 4 ++-- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 test/e2e/labctl.sh diff --git a/test/e2e/labctl.sh b/test/e2e/labctl.sh new file mode 100755 index 0000000..f229a1e --- /dev/null +++ b/test/e2e/labctl.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +LABCTL_VERSION="0.1.0rc001" +LABCTL_URL="https://git.g3e.fr/syonad/labctl/releases/download/${LABCTL_VERSION}" +LABCTL_SUMS="e0c852a8f14f453dedb44e5ef70481293c72a63773dfef166cd298a4da4903e7 labctl_linux_amd64 +3bb13f2088360e332c2c071c7cf070f54956677c6387665b6bef6a58f9e2a631 lab-host.sh" +LABCTL_DIR="${LABCTL_DIR:-${HOME}/.cache/labctl/release/${LABCTL_VERSION}}" + +die () { echo "!! ${1}" >&2; exit 1; } + +sha256 () { + if command -v sha256sum >/dev/null 2>&1; then + sha256sum "$@" + else + shasum -a 256 "$@" + fi +} + +verify () { + (cd "${LABCTL_DIR}" && sha256 -c --quiet - <<< "${LABCTL_SUMS}") >&2 +} + +fetch () { + local asset part + mkdir -p "${LABCTL_DIR}" || return 1 + part="$(mktemp -d "${LABCTL_DIR}/.part.XXXXXX")" || return 1 + for asset in labctl_linux_amd64 lab-host.sh; do + echo "== téléchargement de ${asset} (labctl ${LABCTL_VERSION})" >&2 + curl -fsSL --proto '=https' -o "${part}/${asset}" "${LABCTL_URL}/${asset}" || { rm -rf "${part}"; return 1; } + done + (cd "${part}" && sha256 -c --quiet - <<< "${LABCTL_SUMS}") >&2 || { rm -rf "${part}"; return 1; } + chmod 755 "${part}/labctl_linux_amd64" "${part}/lab-host.sh" || { rm -rf "${part}"; return 1; } + mv "${part}/labctl_linux_amd64" "${part}/lab-host.sh" "${LABCTL_DIR}/" && rm -rf "${part}" +} + +main () { + if ! verify 2>/dev/null; then + fetch || die "labctl ${LABCTL_VERSION} : téléchargement ou vérification des sommes échoué" + verify || die "labctl ${LABCTL_VERSION} : sommes invalides dans ${LABCTL_DIR}" + fi + LABCTL_BIN="${LABCTL_DIR}/labctl_linux_amd64" exec "${LABCTL_DIR}/lab-host.sh" "$@" +} + +if [[ "${BASH_SOURCE[0]}" == "${0}" || -z "${BASH_SOURCE[0]}" ]]; then + main "$@" +fi diff --git a/test/e2e/run.sh b/test/e2e/run.sh index 3a34e7b..d01eb2d 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash LAB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -LAB_HOST="${LAB_HOST:-${LAB_DIR}/../../scripts/lab-host.sh}" +LAB_HOST="${LAB_HOST:-${LAB_DIR}/labctl.sh}" SCENARIO_DIR="${SCENARIO_DIR:-${LAB_DIR}/scenarios}" SCENARIO_LOG="" @@ -11,7 +11,7 @@ usage: ${0##*/} ... | all scénarios : $(cd "${SCENARIO_DIR}" && ls -- *.sh | sed 's/\.sh$//' | tr '\n' ' ') -Chaque scénario s'exécute depuis le Mac sur le lab en cours (lab-host.sh up, push, ./labctl up). +Chaque scénario s'exécute depuis le Mac sur le lab en cours (labctl.sh up, push, ./labctl up). Une ligne RÉUSSI ou ÉCHOUÉ par vérification ; code de sortie 1 si une vérification échoue ou si aucune n'a été faite. USAGE