Skip to content

Commit 6f06953

Browse files
henrywangcgwalters
authored andcommitted
test: Add tests for missing /boot and --bootloader=none
Add two new integration tests: - test-35-install-no-boot-dir: Tests install to-filesystem when /boot directory is absent - test-36-install-bootloader-none: Tests install with --bootloader=none option to skip bootloader management Signed-off-by: Xiaofeng Wang <henrywangxf@me.com>
1 parent 1e1d637 commit 6f06953

File tree

5 files changed

+149
-0
lines changed

5 files changed

+149
-0
lines changed

tmt/plans/integration.fmf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,18 @@ execute:
188188
how: fmf
189189
test:
190190
- /tmt/tests/tests/test-36-rollback
191+
192+
/plan-37-install-no-boot-dir:
193+
summary: Test bootc install to-filesystem without /boot directory
194+
discover:
195+
how: fmf
196+
test:
197+
- /tmt/tests/tests/test-37-install-no-boot-dir
198+
199+
/plan-38-install-bootloader-none:
200+
summary: Test bootc install with --bootloader=none
201+
discover:
202+
how: fmf
203+
test:
204+
- /tmt/tests/tests/test-38-install-bootloader-none
191205
# END GENERATED PLANS

tmt/tests/booted/tap.nu

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,62 @@ export def is_composefs [] {
1818
let st = bootc status --json | from json
1919
$st.status.booted.composefs? != null
2020
}
21+
22+
# Get the target image for install tests based on the running OS
23+
# This ensures the target image matches the host OS to avoid version mismatches
24+
# (e.g., XFS features created by newer mkfs.xfs not recognized by older grub2)
25+
export def get_target_image [] {
26+
# Parse os-release to get ID and VERSION_ID
27+
let os = open /usr/lib/os-release
28+
| lines
29+
| filter {|l| $l != "" and not ($l | str starts-with "#") }
30+
| parse "{key}={value}"
31+
| reduce -f {} {|it, acc|
32+
$acc | upsert $it.key ($it.value | str trim -c '"')
33+
}
34+
35+
let id = $os.ID
36+
let version_id = $os.VERSION_ID
37+
38+
# Construct the key for os-image-map.json
39+
let key = if $id == "centos" {
40+
# CentOS uses "centos-9" or "centos-10" format
41+
$"centos-($version_id)"
42+
} else if $id == "fedora" {
43+
$"fedora-($version_id)"
44+
} else if $id == "rhel" {
45+
# RHEL uses "rhel-9.8" or "rhel-10.2" format
46+
$"rhel-($version_id)"
47+
} else {
48+
# Fallback to centos-9 for unknown distros
49+
"centos-9"
50+
}
51+
52+
# Load the os-image-map.json - try multiple possible locations
53+
let possible_paths = [
54+
"hack/os-image-map.json",
55+
"../../../hack/os-image-map.json",
56+
"/var/home/bootc/hack/os-image-map.json"
57+
]
58+
59+
mut image_map = null
60+
for p in $possible_paths {
61+
if ($p | path exists) {
62+
$image_map = (open $p)
63+
break
64+
}
65+
}
66+
67+
# If map not found, use default centos-9 image
68+
if ($image_map == null) {
69+
return "docker://quay.io/centos-bootc/centos-bootc:stream9"
70+
}
71+
72+
let image = $image_map.base | get -i $key
73+
if ($image | is-empty) {
74+
# Fallback to centos-9 if key not found
75+
$"docker://($image_map.base.centos-9)"
76+
} else {
77+
$"docker://($image)"
78+
}
79+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# number: 38
2+
# tmt:
3+
# summary: Test bootc install with --bootloader=none
4+
# duration: 30m
5+
#
6+
use std assert
7+
use tap.nu
8+
9+
let target_image = (tap get_target_image)
10+
11+
def main [] {
12+
tap begin "install with --bootloader=none"
13+
14+
truncate -s 10G disk.img
15+
16+
setenforce 0
17+
18+
systemd-run -p MountFlags=slave -qdPG -- /bin/sh -c $"
19+
set -xeuo pipefail
20+
bootc usr-overlay
21+
if test -d /sysroot/ostree; then mount --bind /usr/share/empty /sysroot/ostree; fi
22+
rm -vrf /usr/lib/bootupd/updates
23+
rm -vrf /usr/lib/bootc/bound-images.d
24+
# Install with --bootloader=none - skips bootloader management
25+
bootc install to-disk --disable-selinux --via-loopback --filesystem xfs --bootloader=none --source-imgref ($target_image) ./disk.img
26+
"
27+
28+
rm -f disk.img
29+
30+
tap ok
31+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# number: 37
2+
# tmt:
3+
# summary: Test bootc install to-filesystem without /boot directory
4+
# duration: 30m
5+
#
6+
use std assert
7+
use tap.nu
8+
9+
let target_image = (tap get_target_image)
10+
11+
def main [] {
12+
tap begin "install to-filesystem without /boot"
13+
14+
mkdir /var/mnt
15+
truncate -s 10G disk.img
16+
mkfs.ext4 disk.img
17+
mount -o loop disk.img /var/mnt
18+
19+
setenforce 0
20+
21+
systemd-run -p MountFlags=slave -qdPG -- /bin/sh -c $"
22+
set -xeuo pipefail
23+
bootc usr-overlay
24+
if test -d /sysroot/ostree; then mount --bind /usr/share/empty /sysroot/ostree; fi
25+
rm -vrf /usr/lib/bootupd/updates
26+
rm -vrf /usr/lib/bootc/bound-images.d
27+
# Install to filesystem without /boot - skips bootloader management
28+
bootc install to-filesystem --disable-selinux --bootloader=none --source-imgref ($target_image) /var/mnt
29+
"
30+
31+
umount /var/mnt
32+
rm -f disk.img
33+
34+
tap ok
35+
}

tmt/tests/tests.fmf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,13 @@
111111
summary: Test bootc rollback functionality through image switch and rollback cycle
112112
duration: 30m
113113
test: nu booted/test-rollback.nu
114+
115+
/test-37-install-no-boot-dir:
116+
summary: Test bootc install to-filesystem without /boot directory
117+
duration: 30m
118+
test: nu booted/test-install-no-boot-dir.nu
119+
120+
/test-38-install-bootloader-none:
121+
summary: Test bootc install with --bootloader=none
122+
duration: 30m
123+
test: nu booted/test-install-bootloader-none.nu

0 commit comments

Comments
 (0)