From 8b2b0657667b65ddd5ab8979c76d4aae878e6fff Mon Sep 17 00:00:00 2001 From: Marketen Date: Fri, 9 Oct 2026 15:20:54 +0200 Subject: [PATCH] Fix false "Corrupted" images in the first-boot test The image integrity test read image IDs from column 3 of `docker images`. Newer Docker versions changed the default table (IMAGE, ID, DISK USAGE, ...), so column 3 is now the image size: the test ran `docker save 171MB` and reported every image as corrupted on fresh installs, then still said "Test completed successfully". - List and check images with explicit `--format` strings, by repo:tag. - Fix the missing `echo -e` that printed raw escape codes. - Only say "completed successfully" when no image failed. - Log the test to logs/dappnode_test_install.log; it runs on its own console and left no record. - Make the ISO E2E fail when that log reports corrupted images or no success, and fix a `! grep` check that could never fail under set -e. Co-Authored-By: Claude Opus 5.5 --- scripts/dappnode_test_install.sh | 26 +++++++++++++++++++++----- test/e2e_iso_install.sh | 21 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/scripts/dappnode_test_install.sh b/scripts/dappnode_test_install.sh index 4d5d704d..56804f0c 100755 --- a/scripts/dappnode_test_install.sh +++ b/scripts/dappnode_test_install.sh @@ -2,6 +2,11 @@ HOME=${HOME:-/home/dappnode} DAPPNODE_DIR="/usr/src/dappnode" +LOG_FILE="${DAPPNODE_DIR}/logs/dappnode_test_install.log" + +# This runs on its own console, so also keep a log for support and the E2E tests. +mkdir -p "$(dirname "${LOG_FILE}")" +exec > >(tee -a "${LOG_FILE}") 2>&1 error_exit() { echo -e "\e[31m Error on installation!!! \n \e[0m" @@ -51,16 +56,27 @@ for comp in "${components[@]}"; do fi done +# Use explicit formats: the default `docker images` columns differ between +# Docker versions, and newer ones put the image size where the ID used to be. echo -e "\e[32m docker image versions:\e[0m" -docker images | grep dappnode | awk '{print $1, $2}' +docker images --format '{{.Repository}}:{{.Tag}} {{.ID}}' | grep dappnode echo -e "\e[32m doing docker image integrity test...\e[0m" -imgs=$(docker images | grep dappnode | awk '{print $3}') +imgs=$(docker images --format '{{.Repository}}:{{.Tag}}' | grep dappnode) +corrupted_imgs=() for img in $imgs; do - # shellcheck disable=SC2028 - docker save "$img" >/dev/null && echo -ne "\e[32mImage $img OK\n\e[0m" || echo "\e[31mImage $img Corrupted!\n\e[0m" + if docker save "$img" >/dev/null; then + echo -e "\e[32mImage $img OK\e[0m" + else + echo -e "\e[31mImage $img Corrupted!\e[0m" + corrupted_imgs+=("$img") + fi done rm -f /usr/src/dappnode/.firstboot -read -r -p "Test completed successfully. Press enter to continue" +if [ "${#corrupted_imgs[@]}" -gt 0 ]; then + read -r -p "Test completed with corrupted images: ${corrupted_imgs[*]}. Press enter to continue" +else + read -r -p "Test completed successfully. Press enter to continue" +fi diff --git a/test/e2e_iso_install.sh b/test/e2e_iso_install.sh index f993ba6c..9a510e42 100755 --- a/test/e2e_iso_install.sh +++ b/test/e2e_iso_install.sh @@ -485,7 +485,26 @@ test -x /usr/src/dappnode/scripts/dappnode_install.sh test -s /usr/src/dappnode/logs/iso_install.log test -s /usr/src/dappnode/logs/dappnode_install.log test ! -e /usr/src/dappnode/.firstboot -! grep -Fq '/usr/src/dappnode/scripts/dappnode_install.sh' /etc/rc.local +# `! cmd` never trips `set -e`, so negative checks need an explicit exit. +if grep -Fq '/usr/src/dappnode/scripts/dappnode_install.sh' /etc/rc.local; then + echo "[ERROR] rc.local still runs the DAppNode installer" + exit 1 +fi + +# The first-boot self-test runs on its own console; its log is the only record. +first_boot_test_log=/usr/src/dappnode/logs/dappnode_test_install.log +test -s "${first_boot_test_log}" +if grep -Fq 'Corrupted' "${first_boot_test_log}"; then + echo "[ERROR] The first-boot test reported corrupted images:" + grep -F 'Image ' "${first_boot_test_log}" + exit 1 +fi +if ! grep -Fq 'Test completed successfully' "${first_boot_test_log}"; then + echo "[ERROR] The first-boot test did not report success:" + tail -n 30 "${first_boot_test_log}" + exit 1 +fi +grep -F 'Image ' "${first_boot_test_log}" docker --version docker compose version docker info >/dev/null