Skip to content

Commit c9223a7

Browse files
henrywangclaude
andcommitted
tests: Use OS-matched target image in install tests
Add get_target_image function to tap.nu that selects the appropriate bootc target image based on the running OS. This avoids version mismatches (e.g., XFS features created by newer mkfs.xfs not recognized by older grub2). The function parses /usr/lib/os-release and looks up the image from hack/os-image-map.json, with fallbacks for missing configurations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Xiaofeng Wang <henrywangxf@me.com>
1 parent 043cc79 commit c9223a7

5 files changed

Lines changed: 47 additions & 10 deletions

File tree

hack/os-image-map.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{
22
"base": {
33
"rhel-10.2": "images.paas.redhat.com/bootc/rhel-bootc:latest-10.2",
4+
"rhel-10.3": "images.paas.redhat.com/bootc/rhel-bootc:latest-10.3",
45
"rhel-9.8": "images.paas.redhat.com/bootc/rhel-bootc:latest-9.8",
6+
"rhel-9.9": "images.paas.redhat.com/bootc/rhel-bootc:latest-9.9",
57
"centos-9": "quay.io/centos-bootc/centos-bootc:stream9",
68
"centos-10": "quay.io/centos-bootc/centos-bootc:stream10",
79
"fedora-42": "quay.io/fedora/fedora-bootc:42",
810
"fedora-43": "quay.io/fedora/fedora-bootc:43",
911
"fedora-44": "quay.io/fedora/fedora-bootc:44",
10-
"fedora-45": "quay.io/fedora/fedora-bootc:rawhide"
12+
"fedora-45": "quay.io/fedora/fedora-bootc:45"
1113
},
1214
"buildroot-base": {
1315
"centos-9": "quay.io/centos/centos:stream9",
1416
"centos-10": "quay.io/centos/centos:stream10",
1517
"fedora-42": "quay.io/fedora/fedora:42",
1618
"fedora-43": "quay.io/fedora/fedora:43",
1719
"fedora-44": "quay.io/fedora/fedora:44",
18-
"fedora-45": "quay.io/fedora/fedora:rawhide"
20+
"fedora-45": "quay.io/fedora/fedora:45"
1921
}
2022
}

hack/provision-derived.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ if test -z "${SKIP_CONFIGS:-}"; then
136136
install -D -t /usr/lib/bootc/kargs.d test-kargs/*
137137
# Also copy in some default install configs we use for testing
138138
install -D -t /usr/lib/bootc/install/ install-test-configs/*
139+
140+
# Install os-image-map.json for tests that need to select OS-matched images
141+
install -D -m 0644 os-image-map.json /usr/share/bootc/os-image-map.json
139142
else
140143
echo "SKIP_CONFIGS is set, skipping LBIs, test kargs, and install configs"
141144
fi

tmt/tests/booted/tap.nu

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,40 @@ export def is_composefs [] {
1919
$st.status.booted.composefs? != null
2020
}
2121

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 key = $"($os.ID)-($os.VERSION_ID)"
36+
37+
# Load the os-image-map.json - installed location in image
38+
let map_path = "/usr/share/bootc/os-image-map.json"
39+
40+
# If map not found, use default centos-9 image
41+
if not ($map_path | path exists) {
42+
return "docker://quay.io/centos-bootc/centos-bootc:stream9"
43+
}
44+
45+
let image_map = (open $map_path)
46+
47+
let image = $image_map.base | get -i $key
48+
if ($image | is-empty) {
49+
# Fallback to centos-9 if key not found
50+
$"docker://($image_map.base.centos-9)"
51+
} else {
52+
$"docker://($image)"
53+
}
54+
}
55+
2256
# Run a bootc install command in an isolated mount namespace.
2357
# This handles the common setup needed for install tests run outside a container.
2458
export def run_install [cmd: string] {

tmt/tests/booted/test-install-outside-container.nu

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
use std assert
77
use tap.nu
88

9-
# In this test we install a generic image mainly because it keeps
10-
# this test in theory independent of starting from a bootc host,
11-
# but also because it's useful to test "skew" between the bootc binary
12-
# doing the install and the target image.
13-
let target_image = "docker://quay.io/centos-bootc/centos-bootc:stream9"
9+
# Use an OS-matched target image to avoid version mismatches
10+
# (e.g., XFS features created by newer mkfs.xfs not recognized by older grub2)
11+
let target_image = (tap get_target_image)
1412

1513
# setup filesystem
1614
mkdir /var/mnt

tmt/tests/booted/test-install-unified-flag.nu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use std assert
1313
use tap.nu
1414

15-
# Use a generic target image to test skew between the bootc binary doing
16-
# the install and the target image
17-
let target_image = "docker://quay.io/centos-bootc/centos-bootc:stream9"
15+
# Use an OS-matched target image to avoid version mismatches
16+
# (e.g., XFS features created by newer mkfs.xfs not recognized by older grub2)
17+
let target_image = (tap get_target_image)
1818

1919
def main [] {
2020
tap begin "install with experimental unified storage flag"

0 commit comments

Comments
 (0)