Skip to content

Commit 0cfbed7

Browse files
committed
tests: Add sealed composefs case for upgrades
The goal is ensuring we have upgrade coverage also for sealed UKIs; most of the other update code paths (because tmt doesn't make it easy to have a registry) do on-machine synthetic updates. Assisted-by: OpenCode (claude-opus-4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 621e141 commit 0cfbed7

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ test-composefs bootloader filesystem boot_type seal_state *ARGS:
141141
--seal-state={{seal_state}} \
142142
--boot-type={{boot_type}} \
143143
{{ARGS}} \
144-
$(if [ "{{boot_type}}" = "uki" ]; then echo "readonly composefs-upgrade"; else echo "integration"; fi)
144+
$(if [ "{{boot_type}}" = "uki" ]; then echo "readonly image-upgrade-reboot"; else echo "integration"; fi)
145145

146146
# Run upgrade test: boot VM from published base image (with tmt deps added),
147147
# upgrade to locally-built image, reboot, then run readonly tests to verify.

tmt/tests/booted/test-image-upgrade-reboot.nu

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# bootc switch <into that image> --apply
1212
# Verify we boot into the new image
1313
#
14+
# For composefs builds, it additionally verifies that composefs is
15+
# still active after upgrade. For sealed UKI builds, it checks that
16+
# both the original and upgrade UKIs exist on the ESP.
17+
#
1418
use std assert
1519
use tap.nu
1620

@@ -21,6 +25,7 @@ journalctl --list-boots
2125

2226
let st = bootc status --json | from json
2327
let booted = $st.status.booted.image
28+
let is_composefs = (tap is_composefs)
2429

2530
# Parse the kernel commandline into a list.
2631
# This is not a proper parser, but good enough
@@ -50,6 +55,12 @@ RUN touch /usr/share/testing-bootc-upgrade-apply
5055
podman build -t $imgsrc .
5156
}
5257

58+
# For composefs, save state so we can verify it's preserved after upgrade.
59+
if $is_composefs {
60+
"true" | save /var/was-composefs
61+
$st.status.booted.composefs.verity | save /var/original-verity
62+
}
63+
5364
# Now, switch into the new image
5465
print $"Applying ($imgsrc)"
5566
bootc switch --transport containers-storage ($imgsrc)
@@ -63,7 +74,47 @@ def second_boot [] {
6374
assert equal $booted.image.image $"(imgsrc)"
6475

6576
# Verify the new file exists
66-
"/usr/share/testing-bootc-upgrade-apply" | path exists
77+
assert ("/usr/share/testing-bootc-upgrade-apply" | path exists) "upgrade marker file should exist"
78+
79+
# If the previous boot was composefs, verify composefs survived the upgrade
80+
let was_composefs = ("/var/was-composefs" | path exists)
81+
if $was_composefs {
82+
assert $is_composefs "composefs should still be active after upgrade"
83+
84+
let composefs_info = $st.status.booted.composefs
85+
print $"composefs info: ($composefs_info)"
86+
87+
assert (($composefs_info.verity | str length) > 0) "composefs verity digest should be present"
88+
89+
# For UKI boot type, verify both the original and upgrade UKIs exist on the ESP
90+
if ($composefs_info.bootType | str downcase) == "uki" {
91+
let bootloader = ($composefs_info.bootloader | str downcase)
92+
93+
let boot_dir = if $bootloader == "systemd" {
94+
mkdir /var/tmp/efi
95+
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
96+
"/var/tmp/efi/EFI/Linux/bootc"
97+
} else {
98+
"/sysroot/boot/EFI/Linux/bootc"
99+
}
100+
101+
let original_verity = (open /var/original-verity | str trim)
102+
let upgrade_verity = $composefs_info.verity
103+
104+
print $"boot_dir: ($boot_dir)"
105+
print $"original verity: ($original_verity)"
106+
print $"upgrade verity: ($upgrade_verity)"
107+
108+
# The two verities must differ since the upgrade image has different content
109+
assert ($original_verity != $upgrade_verity) "upgrade should produce a different verity digest"
110+
111+
# There should be two .efi UKI files on the ESP: one for the booted
112+
# deployment (upgrade) and one for the rollback (original)
113+
let efi_files = (glob $"($boot_dir)/*.efi")
114+
print $"EFI files: ($efi_files)"
115+
assert (($efi_files | length) >= 2) $"expected at least 2 UKIs on ESP, found ($efi_files | length)"
116+
}
117+
}
67118

68119
tap ok
69120
}

0 commit comments

Comments
 (0)