diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/test-install.sh | 144 |
1 files changed, 83 insertions, 61 deletions
diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 3783ce8..6cde83f 100755 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -718,72 +718,62 @@ run_install() { return 0 } -# Verify installation +# Succeed when an install log carries the installer's completion banner. +# Pure: takes the log text. +# +# Usage: install_log_reports_success "$log_text" +install_log_reports_success() { + grep -qF 'Installation Complete!' <<<"$1" +} + +# Succeed when `zpool import` output lists <pool> as importable. Matches the +# "pool:" header line only, so a vdev or a longer pool name can't match. +# Pure: takes the command's output. +# +# Usage: zpool_import_lists_pool "$zpool_import_output" <pool> +zpool_import_lists_pool() { + grep -Eq "^[[:space:]]*pool: ${2}\$" <<<"$1" +} + +# Pre-reboot checks, run on the live ISO right after the installer returns. +# Everything here goes over the live ISO's own SSH, which every config has: +# ENABLE_SSH only governs the installed system. Checks of the running +# installed system (Avahi, the Btrfs genesis snapshot) live in +# verify_reboot_survival, because the target isn't there to look at yet. verify_install() { local config="$1" - local enable_ssh - local filesystem - enable_ssh=$(grep "^ENABLE_SSH=" "$config" | cut -d= -f2) + local filesystem install_log import_out filesystem=$(grep "^FILESYSTEM=" "$config" | cut -d= -f2) filesystem="${filesystem:-zfs}" # Default to ZFS - # Basic checks via SSH (if enabled) - if [[ "$enable_ssh" == "yes" ]]; then - # Check install log for success indicators - if ssh_cmd "grep -q 'Installation complete' /tmp/archangel-*.log 2>/dev/null"; then - info "Install log shows success" - else - warn "Could not verify install log" - fi - - if [[ "$filesystem" == "zfs" ]]; then - # ZFS-specific checks - if ssh_cmd "zpool list zroot" >/dev/null 2>&1; then - info "ZFS pool 'zroot' exists" - else - error "ZFS pool 'zroot' not found" - return 1 - fi - - if ssh_cmd "zfs list -t snapshot | grep -q genesis"; then - info "ZFS genesis snapshot exists" - else - warn "ZFS genesis snapshot not found" - fi - elif [[ "$filesystem" == "btrfs" ]]; then - # Btrfs-specific checks - if ssh_cmd "btrfs subvolume list /mnt" >/dev/null 2>&1; then - info "Btrfs subvolumes exist" - else - error "Btrfs subvolumes not found" - return 1 - fi - - if ssh_cmd "arch-chroot /mnt snapper -c root list 2>/dev/null | grep -q genesis"; then - info "Btrfs genesis snapshot exists" - else - warn "Btrfs genesis snapshot not found" - fi - fi - - # Check Avahi mDNS packages - if ssh_cmd "arch-chroot /mnt pacman -Q avahi nss-mdns >/dev/null 2>&1"; then - info "Avahi packages installed" - else - warn "Avahi packages not found" - fi + install_log=$(ssh_cmd "cat \"\$(ls -t /tmp/archangel-*.log 2>/dev/null | head -1)\"" 2>/dev/null) || true + if install_log_reports_success "$install_log"; then + info "Install log shows success" + else + error "Install log has no \"Installation Complete!\" banner" + return 1 + fi - if ssh_cmd "arch-chroot /mnt systemctl is-enabled avahi-daemon >/dev/null 2>&1"; then - info "Avahi daemon enabled" + if [[ "$filesystem" == "zfs" ]]; then + # The installer exports zroot on its way out, so `zpool list` can't + # see it here. A clean export leaves it importable, and that's the + # check. The @genesis snapshot is asserted after the reboot. + import_out=$(ssh_cmd "zpool import 2>&1") || true + if zpool_import_lists_pool "$import_out" zroot; then + info "ZFS pool 'zroot' exported cleanly and importable" else - warn "Avahi daemon not enabled" + error "ZFS pool 'zroot' is not importable after the install" + return 1 fi - else - # For no-SSH tests, check serial console output - if grep -q "Installation complete" "$SERIAL_LOG" 2>/dev/null; then - info "Serial console shows installation complete" + elif [[ "$filesystem" == "btrfs" ]]; then + # This reads /mnt, which a successful Btrfs install currently leaves + # mounted. Once the installer's success path unmounts properly, this + # check has to move after the reboot or it fails every Btrfs run. + if ssh_cmd "btrfs subvolume list /mnt" >/dev/null 2>&1; then + info "Btrfs subvolumes exist" else - warn "Could not verify installation via serial console" + error "Btrfs subvolumes not found" + return 1 fi fi @@ -846,6 +836,34 @@ verify_reboot_survival() { else warn "Snapper timeline timer not active" fi + + # snapper-firstboot creates the genesis snapshot on the first boot, + # possibly after SSH is already up, so give it a minute. + local i genesis=no + for ((i = 0; i < 12; i++)); do + if ssh_cmd "snapper -c root list 2>/dev/null | grep -q genesis"; then + genesis=yes + break + fi + sleep 5 + done + if [[ "$genesis" == yes ]]; then + info "Btrfs genesis snapshot exists" + else + warn "Btrfs genesis snapshot not found after first boot" + fi + fi + + # mDNS on the installed system + if ssh_cmd "pacman -Q avahi nss-mdns >/dev/null 2>&1"; then + info "Avahi packages installed" + else + warn "Avahi packages not found" + fi + if ssh_cmd "systemctl is-enabled avahi-daemon >/dev/null 2>&1"; then + info "Avahi daemon enabled" + else + warn "Avahi daemon not enabled" fi return 0 @@ -1245,11 +1263,15 @@ run_test() { # Verify installation (while still in live ISO) step "Verifying installation..." - if verify_install "$config"; then - info "Verification passed" - else - warn "Verification had issues (may be expected if install rebooted)" + if ! verify_install "$config"; then + error "Pre-reboot verification failed (see above)" + stop_vm "$config_name" + cleanup_disks "$config_name" + TESTS_FAILED=$((TESTS_FAILED + 1)) + FAILED_TESTS+=("$config_name") + return 1 fi + info "Verification passed" # Stop VM to prepare for reboot test (keep OVMF vars for EFI boot) step "Stopping VM for reboot test..." |
