Skip to content

Commit d5f114f

Browse files
test wip
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent dd314c9 commit d5f114f

5 files changed

Lines changed: 208 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -160,38 +160,36 @@ jobs:
160160
fail-fast: false
161161
matrix:
162162
# No fedora-44 due to https://bugzilla.redhat.com/show_bug.cgi?id=2429501
163-
test_os: [fedora-43, centos-9, centos-10]
164-
variant: [ostree, composefs]
165-
filesystem: ["ext4", "xfs"]
166-
bootloader: ["grub", "systemd"]
167-
boot_type: ["bls", "uki"]
168-
seal_state: ["sealed", "unsealed"]
169-
170-
exclude:
163+
test_os: [fedora-43]
164+
variant: [composefs]
165+
filesystem: ["ext4"]
166+
bootloader: ["systemd"]
167+
boot_type: ["bls"]
168+
seal_state: ["unsealed"]
169+
170+
# exclude:
171171
# centos-9 fails with EUCLEAN (https://github.com/bootc-dev/bootc/issues/1812)
172172
# See: https://github.com/bootc-dev/bcvk/pull/204
173-
- test_os: centos-9
174-
variant: composefs
175-
- seal_state: "sealed"
176-
boot_type: bls
177-
- seal_state: "sealed"
178-
bootloader: grub
179-
- seal_state: "sealed"
180-
filesystem: xfs
181-
- seal_state: "unsealed"
182-
filesystem: ext4
183-
boot_type: uki # we still want to test ext4 unsealed bls
184-
- bootloader: grub
185-
boot_type: "uki"
186-
187-
# We only test filesystems for composefs to test if composefs backend will work on fs
188-
# without fsverity
189-
- variant: ostree
190-
filesystem: ext4
191-
- variant: ostree
192-
boot_type: uki
193-
- variant: ostree
194-
bootloader: systemd
173+
# - seal_state: "sealed"
174+
# boot_type: bls
175+
# - seal_state: "sealed"
176+
# bootloader: grub
177+
# - seal_state: "sealed"
178+
# filesystem: xfs
179+
# - seal_state: "unsealed"
180+
# filesystem: ext4
181+
# boot_type: uki # we still want to test ext4 unsealed bls
182+
# - bootloader: grub
183+
# boot_type: "uki"
184+
#
185+
# # We only test filesystems for composefs to test if composefs backend will work on fs
186+
# # without fsverity
187+
# - variant: ostree
188+
# filesystem: ext4
189+
# - variant: ostree
190+
# boot_type: uki
191+
# - variant: ostree
192+
# bootloader: systemd
195193

196194
runs-on: ubuntu-24.04
197195

Justfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ test-container: build build-units
117117
podman run --rm --env=BOOTC_variant={{variant}} --env=BOOTC_base={{base}} --env=BOOTC_boot_type={{boot_type}} {{base_img}} bootc-integration-tests container
118118

119119
[group('core')]
120-
test-composefs bootloader filesystem boot_type seal_state:
120+
test-composefs bootloader filesystem boot_type seal_state *ARGS:
121121
@if [ "{{seal_state}}" = "sealed" ] && [ "{{filesystem}}" = "xfs" ]; then \
122122
echo "Invalid combination: sealed requires filesystem that supports fs-verity (ext4, btrfs)"; \
123123
exit 1; \
@@ -138,7 +138,8 @@ test-composefs bootloader filesystem boot_type seal_state:
138138
--filesystem={{filesystem}} \
139139
--seal-state={{seal_state}} \
140140
--boot-type={{boot_type}} \
141-
$(if [ "{{boot_type}}" = "uki" ]; then echo "readonly"; else echo "integration"; fi)
141+
{{ARGS}} \
142+
$(if [ "{{boot_type}}" = "uki" ]; then echo "readonly"; else echo "composefs-gc"; fi)
142143

143144
# Run cargo fmt and clippy checks in container
144145
[group('core')]

tmt/plans/integration.fmf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ execute:
182182
test:
183183
- /tmt/tests/tests/test-34-user-agent
184184

185+
/plan-35-composefs-gc:
186+
summary: Test composefs garbage collection with same and different kernel+initrd
187+
discover:
188+
how: fmf
189+
test:
190+
- /tmt/tests/tests/test-35-composefs-gc
191+
185192
/plan-36-rollback:
186193
summary: Test bootc rollback functionality through image switch and rollback cycle
187194
discover:
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# number: 35
2+
# tmt:
3+
# summary: Test composefs garbage collection with same and different kernel+initrd
4+
# duration: 45m
5+
6+
use std assert
7+
use tap.nu
8+
9+
$env.RUST_LOG = "debug"
10+
11+
# bootc status
12+
let st = bootc status --json | from json
13+
let booted = $st.status.booted.image
14+
15+
if not (tap is_composefs) {
16+
exit 0
17+
}
18+
19+
def get_podman_image_id [image_name: string] {
20+
let id = (podman inspect --format '{{.Id}}' $image_name | str trim)
21+
22+
let full_id = if ($id | str starts-with "sha256:") {
23+
$id
24+
} else {
25+
$"sha256:($id)"
26+
}
27+
28+
$full_id
29+
}
30+
31+
# Create a large file in a new container image, then bootc switch to the image
32+
def first_boot [] {
33+
bootc image copy-to-storage
34+
35+
echo $"
36+
FROM localhost/bootc
37+
RUN dd if=/dev/zero of=/usr/share/large-test-file bs=1k count=1337
38+
RUN echo 'large-file-marker' | dd of=/usr/share/large-test-file conv=notrunc
39+
" | podman build -t localhost/bootc-derived . -f -
40+
41+
let current_time = (date now)
42+
43+
bootc switch --transport containers-storage localhost/bootc-derived
44+
45+
# Find the large file's verity and save it
46+
# nu has its own built in find which sucks, so we use the other one
47+
# TODO: Replace this
48+
let file_path = (
49+
/usr/bin/find /sysroot/composefs/objects -type f -size 1337k -newermt ($current_time | format date "%Y-%m-%d %H:%M:%S")
50+
| xargs grep -lx "large-file-marker"
51+
)
52+
53+
echo $file_path | save /var/large-file-marker-objpath
54+
55+
echo "cat /var/large-file-marker-objpath"
56+
cat /var/large-file-marker-objpath
57+
58+
tmt-reboot
59+
}
60+
61+
# Create a container image derived from the first boot image, but update the initrd
62+
def second_boot [] {
63+
assert equal $booted.image.image "localhost/bootc-derived"
64+
65+
let path = cat /var/large-file-marker-objpath
66+
67+
echo "\$path"
68+
echo $path
69+
70+
assert ($path | path exists)
71+
72+
# Create another image with a different initrd so we can test kernel + initrd cleanup
73+
74+
echo "
75+
FROM localhost/bootc
76+
77+
RUN echo 'echo hello' > /usr/bin/hello
78+
RUN chmod +x /usr/bin/hello
79+
80+
RUN mkdir /usr/lib/dracut/modules.d/99something
81+
82+
RUN cat <<-EOF > /usr/lib/dracut/modules.d/99something/module-setup.sh
83+
#!/usr/bin/bash
84+
85+
check() {
86+
return 0
87+
}
88+
89+
depends() {
90+
return 0
91+
}
92+
93+
install() {
94+
inst '/usr/bin/hello' /bin/hello
95+
}
96+
EOF
97+
98+
RUN set -x; kver=$(cd /usr/lib/modules && echo *); dracut -vf /usr/lib/modules/$kver/initramfs.img $kver;
99+
" | lines | each { str trim } | str join "\n" | podman build -t localhost/bootc-derived-initrd . -f -
100+
101+
bootc switch --transport containers-storage localhost/bootc-derived-initrd
102+
103+
tmt-reboot
104+
}
105+
106+
# The large file should've been GC'd as we switched to an image derived from the original one
107+
def third_boot [] {
108+
assert equal $booted.image.image "localhost/bootc-derived-initrd"
109+
110+
let path = cat /var/large-file-marker-objpath
111+
assert (not ($"/sysroot/composefs/objects/($path)" | path exists))
112+
113+
# Also assert we have two different kernel + initrd pairs
114+
let booted_verity = (bootc status --json | from json).status.booted.composefs.verity
115+
let rollback_verity = (bootc status --json | from json).status.rollback.composefs.verity
116+
117+
let bootloader = (bootc status --json | from json).status.booted.composefs.bootloader
118+
119+
let boot_dir = if ($bootloader | str downcase) == "systemd" {
120+
mkdir /sysroot/boot/efi
121+
mount /dev/vdb2 /sysroot/boot/efi
122+
123+
"/sysroot/boot/efi/EFI/Linux"
124+
} else {
125+
"/sysroot/boot"
126+
}
127+
128+
assert ($"($boot_dir)/($booted_verity)" | path exists)
129+
assert ($"($boot_dir)/($rollback_verity)" | path exists)
130+
131+
echo $"($boot_dir)/($booted_verity)" | save /var/to-be-deleted-kernel
132+
133+
# Now we create a new image derived from the current kernel + initrd
134+
# Switching to this and rebooting should remove the old kernel + initrd
135+
echo "
136+
FROM localhost/bootc-derived-initrd
137+
RUN echo 'another file' > /usr/share/another-one
138+
" | podman build -t localhost/bootc-final . -f -
139+
140+
141+
bootc switch --transport containers-storage localhost/bootc-final
142+
143+
tmt-reboot
144+
}
145+
146+
def fourth_boot [] {
147+
assert equal $booted.image.image "localhost/bootc-final"
148+
assert (not ((cat /var/to-be-deleted-kernel | path exists)))
149+
150+
tap ok
151+
}
152+
153+
def main [] {
154+
# Ensure we're running on composefs
155+
assert (tap is_composefs)
156+
157+
match $env.TMT_REBOOT_COUNT? {
158+
null | "0" => first_boot,
159+
"1" => second_boot,
160+
"2" => third_boot,
161+
"3" => fourth_boot,
162+
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
163+
}
164+
}
165+

tmt/tests/tests.fmf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@
102102
duration: 10m
103103
test: python3 booted/test-user-agent.py
104104

105+
/test-35-composefs-gc:
106+
summary: Test composefs garbage collection with same and different kernel+initrd
107+
duration: 45m
108+
test: nu --log-level=debug booted/test-composefs-gc.nu
109+
105110
/test-35-upgrade-preflight-disk-check:
106111
summary: Verify pre-flight disk space check rejects images with inflated layer sizes
107112
duration: 20m

0 commit comments

Comments
 (0)