Skip to content

Commit b636d08

Browse files
committed
tests: Add integration coverage for switch --from-delta
Exercise offline delta switching on booted Fedora systems with the ostree and composefs backends. Build a derived target in the guest and create its delta against an archive of the original install image. Remove the target from container storage, apply the delta, and verify the image digest and marker file after reboot. Disable /boot automount idle expiry on ostree so shutdown finalization can activate the staged deployment. Skip sealed UKI cases because the guest-local builder produces unsigned images. Generated-by: AI Signed-off-by: Alexander Larsson <alexl@redhat.com>
1 parent 03c5c8c commit b636d08

4 files changed

Lines changed: 123 additions & 1 deletion

File tree

‎hack/provision-fetch.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ case "${ID}-${VERSION_ID}" in
4343
rm -rf "${td}"
4444
;;
4545
"fedora-"*)
46-
dnf -y install nu
46+
dnf -y install nu oci-delta
4747
;;
4848
esac
4949

‎tmt/plans/integration.fmf‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,23 @@ execute:
344344
because: only the image_mode test image installs bootc-tests
345345
extra-skip_if_ostree: true
346346

347+
/plan-51-switch-from-delta:
348+
summary: Switch to a derived image using an OCI delta and verify after reboot
349+
discover:
350+
how: fmf
351+
test:
352+
- /tmt/tests/tests/test-51-switch-from-delta
353+
adjust:
354+
- when: distro != fedora
355+
enabled: false
356+
because: oci-delta is packaged in Fedora
357+
- when: boot_type == uki and seal_state == sealed
358+
enabled: false
359+
because: the guest-local UKI builder produces unsigned images
360+
extra-export_image: true
361+
environment:
362+
BOOTC_source_image_archive: /sysroot/bootc-source.oci.tar
363+
347364
/plan-52-install-repart:
348365
summary: Test bootc install to-disk with systemd-repart partitioning
349366
discover:
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# number: 51
2+
# extra:
3+
# export_image: true
4+
# tmt:
5+
# summary: Switch to a derived image using an OCI delta and verify after reboot
6+
# duration: 30m
7+
# adjust:
8+
# - when: distro != fedora
9+
# enabled: false
10+
# because: oci-delta is packaged in Fedora
11+
# - when: boot_type == uki and seal_state == sealed
12+
# enabled: false
13+
# because: the guest-local UKI builder produces unsigned images
14+
#
15+
use std assert
16+
use tap.nu
17+
18+
const image = "localhost/bootc-delta-target:latest"
19+
const delta = "/var/tmp/image-1-to-2.oci-delta"
20+
const state = "/var/tmp/bootc-delta-state.json"
21+
const marker = "/usr/share/testing-bootc-delta"
22+
23+
def initial_build [] {
24+
tap begin "switch from OCI delta"
25+
assert (not ($marker | path exists))
26+
let st = bootc status --json | from json
27+
28+
if not (tap is_composefs) {
29+
let automounted = (
30+
do { ^findmnt --mountpoint /boot --types autofs --noheadings } | complete
31+
).exit_code == 0
32+
if $automounted {
33+
# An expired /boot breaks ostree finalization: https://github.com/bootc-dev/bootc/issues/2402
34+
let dropin = "/etc/systemd/system/boot.automount.d/bootc-delta-test.conf"
35+
mkdir ($dropin | path dirname)
36+
"[Automount]\nTimeoutIdleSec=0\n" | save $dropin
37+
systemctl daemon-reload
38+
systemctl restart boot.automount
39+
}
40+
}
41+
42+
let source_archive = $env.BOOTC_source_image_archive? | default "/sysroot/bootc-source.oci.tar"
43+
assert ($source_archive | path exists) $"Missing source image archive: ($source_archive)"
44+
skopeo copy $"oci-archive:($source_archive)" containers-storage:localhost/bootc
45+
46+
(tap make_uki_containerfile $"
47+
FROM localhost/bootc as base
48+
RUN echo delta-upgrade > ($marker)
49+
") | save Dockerfile
50+
podman build --network=none -t $image .
51+
52+
let target = skopeo inspect $"containers-storage:($image)" | from json
53+
let reference = $"localhost/bootc-delta-target@($target.Digest)"
54+
assert ($target.Digest != $st.status.booted.image.imageDigest)
55+
56+
oci-delta create $"oci-archive:($source_archive)" $"containers-storage:($image)" $delta
57+
# Keep the target available only through the delta.
58+
podman rmi $image
59+
60+
{
61+
image: $reference
62+
digest: $target.Digest
63+
composefs: (tap is_composefs)
64+
} | to json | save $state
65+
66+
bootc switch --from-delta $delta $reference
67+
let staged = (bootc status --json | from json).status.staged.image
68+
assert equal $staged.image.transport registry
69+
assert equal $staged.image.image $reference
70+
assert equal $staged.imageDigest $target.Digest
71+
assert (not ($marker | path exists))
72+
tmt-reboot
73+
}
74+
75+
def verify_delta [] {
76+
let expected = open $state
77+
let booted = (bootc status --json | from json).status.booted.image
78+
assert equal $booted.image.transport registry
79+
assert equal $booted.image.image $expected.image
80+
assert equal $booted.imageDigest $expected.digest
81+
assert equal (open $marker | str trim) delta-upgrade
82+
assert equal (tap is_composefs) $expected.composefs
83+
bootc internals fsck
84+
tap ok
85+
}
86+
87+
def main [] {
88+
match $env.TMT_REBOOT_COUNT? {
89+
null | "0" => initial_build,
90+
"1" => verify_delta,
91+
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
92+
}
93+
}

‎tmt/tests/tests.fmf‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ check:
216216
because: only the image_mode test image installs bootc-tests
217217
test: bootc-integration-tests booted switch-zstd-chunked
218218

219+
/test-51-switch-from-delta:
220+
summary: Switch to a derived image using an OCI delta and verify after reboot
221+
duration: 30m
222+
adjust:
223+
- when: distro != fedora
224+
enabled: false
225+
because: oci-delta is packaged in Fedora
226+
- when: boot_type == uki and seal_state == sealed
227+
enabled: false
228+
because: the guest-local UKI builder produces unsigned images
229+
test: nu booted/test-switch-from-delta.nu
230+
219231
/test-52-install-repart:
220232
summary: Test bootc install to-disk with systemd-repart partitioning
221233
duration: 30m

0 commit comments

Comments
 (0)