aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-10-24 05:52:42 -0500
committerCraig Jennings <c@cjennings.net>2026-10-24 05:52:42 -0500
commit02066b7106eef6f2ab3ed12de4ad2fbf3a83d669 (patch)
tree1b1e712223a5a3e7c0769bd2c357f0ed8d5bb745 /tests/unit
parent1ea3434be0bf6f66f1a3828ef0e4a6e0a6b8a761 (diff)
downloadarchangel-main.tar.gz
archangel-main.zip
fix(test): verify installations from the live ISOHEADmain
I read the exact completion banner for every config and check exported ZFS pools with zpool import. Failed pre-reboot checks stop the scenario before it can count as passed. I moved checks that need the running target into the post-reboot path.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_test_install.bats113
1 files changed, 113 insertions, 0 deletions
diff --git a/tests/unit/test_test_install.bats b/tests/unit/test_test_install.bats
index ab3541b..8e1e9d1 100644
--- a/tests/unit/test_test_install.bats
+++ b/tests/unit/test_test_install.bats
@@ -57,6 +57,119 @@ setup() {
}
#############################
+# install_log_reports_success
+#############################
+# verify_install grepped for "Installation complete", but the installer's
+# banner is "Installation Complete!", so the check never passed on any run.
+
+@test "install_log_reports_success matches the installer's completion banner" {
+ local log="==> Cleaning Up
+╔═══════════════════════════════════════════════════════════════╗
+║ Installation Complete! ║
+╚═══════════════════════════════════════════════════════════════╝"
+ run install_log_reports_success "$log"
+ [ "$status" -eq 0 ]
+}
+
+@test "install_log_reports_success rejects a failed install's log" {
+ local log="[WARN] Installation failed (exit code 1) — cleaning up...
+[ERROR] Installation failed; system cleaned up. Re-run the installer to retry."
+ run install_log_reports_success "$log"
+ [ "$status" -eq 1 ]
+}
+
+@test "install_log_reports_success rejects a lowercase near-miss" {
+ run install_log_reports_success "Installation complete"
+ [ "$status" -eq 1 ]
+}
+
+@test "install_log_reports_success rejects an empty log" {
+ run install_log_reports_success ""
+ [ "$status" -eq 1 ]
+}
+
+#############################
+# zpool_import_lists_pool
+#############################
+# The installer exports the pool on its way out, so before the reboot the
+# only pool state the live ISO can see is `zpool import`'s list of
+# importable pools. verify_install used `zpool list`, which never found it.
+
+@test "zpool_import_lists_pool finds an exported pool by name" {
+ local out=" pool: zroot
+ id: 1446521829418224377
+ state: ONLINE
+ action: The pool can be imported using its name or numeric identifier.
+ config:
+
+ zroot ONLINE
+ vda2 ONLINE"
+ run zpool_import_lists_pool "$out" zroot
+ [ "$status" -eq 0 ]
+}
+
+@test "zpool_import_lists_pool ignores a pool whose name only starts with the target" {
+ local out=" pool: zrootbak
+ id: 99
+ state: ONLINE"
+ run zpool_import_lists_pool "$out" zroot
+ [ "$status" -eq 1 ]
+}
+
+@test "zpool_import_lists_pool ignores the pool name appearing only in the config tree" {
+ local out=" pool: tank
+ config:
+
+ zroot ONLINE"
+ run zpool_import_lists_pool "$out" zroot
+ [ "$status" -eq 1 ]
+}
+
+@test "zpool_import_lists_pool fails when no pools are available" {
+ run zpool_import_lists_pool "no pools available to import" zroot
+ [ "$status" -eq 1 ]
+}
+
+@test "zpool_import_lists_pool fails on empty output" {
+ run zpool_import_lists_pool "" zroot
+ [ "$status" -eq 1 ]
+}
+
+#############################
+# run_test verification gate
+#############################
+# A failed live-ISO verification must fail the scenario before reboot. This
+# matters most when ENABLE_SSH=no: the later console marker proves only that
+# something reached a login prompt, not that the installed ZFS root was the
+# pool the installer just created.
+
+@test "run_test fails when pre-reboot verification fails" {
+ local cfg="$BATS_TEST_TMPDIR/no-ssh.conf"
+ printf '%s\n' \
+ 'DISKS=/dev/vda' \
+ 'FILESYSTEM=zfs' \
+ 'ENABLE_SSH=no' > "$cfg"
+
+ LOG_DIR="$BATS_TEST_TMPDIR/logs"
+ SERIAL_LOG="$BATS_TEST_TMPDIR/serial.log"
+ create_disks() { :; }
+ port_in_use() { return 1; }
+ start_vm() { printf '12345\n'; }
+ wait_for_ssh() { return 0; }
+ timeout() { return 0; }
+ verify_install() { return 1; }
+ stop_vm() { :; }
+ cleanup_disks() { :; }
+ boot_from_disk() { return 0; }
+ wait_for_boot_console() { return 0; }
+
+ run run_test "$cfg"
+ [ "$status" -eq 1 ]
+ [[ "$output" == *"Pre-reboot verification failed"* ]]
+ [[ "$output" != *"TEST PASSED"* ]]
+}
+
+#############################
# is_transient_install_failure
#############################