Skip to content

Commit 6905895

Browse files
authored
Merge pull request #1420 from rsturla/systemd-run-reboot-test
test: add integration tests for 'bootc switch --apply'
2 parents 584a754 + 7cef4c5 commit 6905895

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

tmt/plans/integration.fmf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,11 @@ execute:
5454
test:
5555
- /tmt/tests/bootc-install-provision
5656
- /tmt/tests/test-23-install-outside-container
57+
58+
/test-24-local-upgrade-reboot:
59+
summary: Execute local upgrade tests with automated reboot
60+
discover:
61+
how: fmf
62+
test:
63+
- /tmt/tests/bootc-install-provision
64+
- /tmt/tests/test-24-local-upgrade-reboot
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This test does:
2+
# bootc image copy-to-storage
3+
# podman build <from that image>
4+
# bootc switch <into that image> --apply
5+
# Verify we boot into the new image
6+
#
7+
use std assert
8+
use tap.nu
9+
10+
# This code runs on *each* boot.
11+
# Here we just capture information.
12+
bootc status
13+
let st = bootc status --json | from json
14+
let booted = $st.status.booted.image
15+
16+
# Parse the kernel commandline into a list.
17+
# This is not a proper parser, but good enough
18+
# for what we need here.
19+
def parse_cmdline [] {
20+
open /proc/cmdline | str trim | split row " "
21+
}
22+
23+
# Run on the first boot
24+
def initial_build [] {
25+
tap begin "local image push + pull + upgrade"
26+
27+
bootc image copy-to-storage
28+
29+
# A simple derived container that adds a file
30+
"FROM localhost/bootc
31+
RUN touch /usr/share/testing-bootc-upgrade-apply
32+
" | save Dockerfile
33+
# Build it
34+
podman build -t localhost/bootc-derived .
35+
36+
# Now, switch into the new image
37+
tmt-reboot -c "bootc switch --apply --transport containers-storage localhost/bootc-derived"
38+
39+
# We cannot perform any other checks here since the system will be automatically rebooted
40+
}
41+
42+
# Check we have the updated image
43+
def second_boot [] {
44+
print "verifying second boot"
45+
assert equal $booted.image.transport containers-storage
46+
assert equal $booted.image.image localhost/bootc-derived
47+
48+
# Verify the new file exists
49+
"/usr/share/testing-bootc-upgrade-apply" | path exists
50+
51+
tap ok
52+
}
53+
54+
def main [] {
55+
# See https://tmt.readthedocs.io/en/stable/stories/features.html#reboot-during-test
56+
match $env.TMT_REBOOT_COUNT? {
57+
null | "0" => initial_build,
58+
"1" => second_boot,
59+
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
60+
}
61+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
summary: Execute local upgrade tests
2+
test: nu booted/test-image-upgrade-reboot.nu
3+
duration: 30m

0 commit comments

Comments
 (0)