Skip to content

Commit 0667cbf

Browse files
test: Update composefs GC test
Now that we immediately remove unreferenced bootloader binaries, update tests to test for the same Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 7f21931 commit 0667cbf

2 files changed

Lines changed: 11 additions & 62 deletions

File tree

tmt/tests/booted/test-composefs-gc-uki.nu

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,8 @@ def first_boot [] {
4141
bootc switch --transport containers-storage localhost/bootc-first
4242

4343
# Find the large file's verity and save it
44-
# nu has its own built in find which sucks, so we use the other one
45-
# TODO: Replace this with some concrete API
46-
# See: https://github.com/composefs/composefs-rs/pull/236
47-
let file_path = (
48-
/usr/bin/find /sysroot/composefs/objects -type f -size 1337k -newermt ($current_time | format date "%Y-%m-%d %H:%M:%S")
49-
| xargs grep -lx "large-file-marker"
50-
)
51-
52-
echo $file_path | save /var/large-file-marker-objpath
53-
cat /var/large-file-marker-objpath
44+
let path = bootc internals cfs dump-files $st.status.booted.composefs.verity /usr/share/large-test-file --backing-path-only | awk '{print $2}'
45+
echo $"/sysroot/composefs/objects/($path)" | save /var/large-file-marker-objpath
5446

5547
echo $st.status.booted.composefs.verity | save /var/boot0-verity
5648

@@ -68,7 +60,7 @@ def second_boot [] {
6860
echo $st.status.booted.composefs.verity | save /var/boot1-verity
6961

7062
let path = cat /var/large-file-marker-objpath
71-
63+
print $path
7264
assert ($path | path exists)
7365

7466
mut containerfile = echo "
@@ -90,7 +82,7 @@ def third_boot [] {
9082
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
9183

9284
assert equal $booted.image.image "localhost/bootc-second"
93-
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot0-verity).efi" | path exists)
85+
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot0-verity).efi" | path exists))
9486
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists)
9587

9688
echo $st.status.booted.composefs.verity | save /var/boot2-verity
@@ -119,8 +111,7 @@ def fourth_boot [] {
119111
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
120112

121113
assert equal $booted.image.image "localhost/bootc-third"
122-
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot0-verity).efi" | path exists))
123-
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists)
114+
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists))
124115
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot2-verity).efi" | path exists)
125116

126117
echo $st.status.booted.composefs.verity | save /var/boot3-verity
@@ -138,29 +129,12 @@ def fourth_boot [] {
138129
tap ok
139130
}
140131

141-
def fifth_boot [] {
142-
mkdir /var/tmp/efi
143-
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
144-
145-
assert equal $booted.image.image "localhost/bootc-final"
146-
147-
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists))
148-
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot2-verity).efi" | path exists)
149-
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot3-verity).efi" | path exists)
150-
151-
# We had this in boot1 (second boot)
152-
let path = cat /var/large-file-marker-objpath
153-
assert (not ($path | path exists))
154-
tap ok
155-
}
156-
157132
def main [] {
158133
match $env.TMT_REBOOT_COUNT? {
159134
null | "0" => first_boot,
160135
"1" => second_boot,
161136
"2" => third_boot,
162137
"3" => fourth_boot,
163-
"4" => fifth_boot,
164138
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
165139
}
166140
}

tmt/tests/booted/test-composefs-gc.nu

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,8 @@ def first_boot [] {
3535
bootc switch --transport containers-storage localhost/bootc-derived
3636

3737
# Find the large file's verity and save it
38-
# nu has its own built in find which sucks, so we use the other one
39-
# TODO: Replace this with some concrete API
40-
# See: https://github.com/composefs/composefs-rs/pull/236
41-
let file_path = (
42-
/usr/bin/find /sysroot/composefs/objects -type f -size 1337k -newermt ($current_time | format date "%Y-%m-%d %H:%M:%S")
43-
| xargs grep -lx "large-file-marker"
44-
)
45-
46-
echo $file_path | save /var/large-file-marker-objpath
47-
cat /var/large-file-marker-objpath
38+
let path = bootc internals cfs dump-files $st.status.booted.composefs.verity /usr/share/large-test-file --backing-path-only | awk '{print $2}'
39+
echo $"/sysroot/composefs/objects/($path)" | save /var/large-file-marker-objpath
4840

4941
echo $st.status.booted.composefs.verity | save /var/first-verity
5042

@@ -132,22 +124,6 @@ def third_boot [] {
132124
}
133125

134126
def fourth_boot [] {
135-
assert equal $booted.image.image "localhost/bootc-prefinal"
136-
137-
# Now we create a new image derived from the current kernel + initrd
138-
# Switching to this and rebooting should remove the old kernel + initrd
139-
echo "
140-
FROM localhost/bootc-derived-initrd
141-
RUN echo 'another file 1' > /usr/share/another-one-1
142-
" | podman build -t localhost/bootc-final . -f -
143-
144-
145-
bootc switch --transport containers-storage localhost/bootc-final
146-
147-
tmt-reboot
148-
}
149-
150-
def fifth_boot [] {
151127
let bootloader = (bootc status --json | from json).status.booted.composefs.bootloader
152128

153129
if ($bootloader | str downcase) == "systemd" {
@@ -177,7 +153,7 @@ def fifth_boot [] {
177153
tmt-reboot
178154
}
179155

180-
def sixth_boot [i: int] {
156+
def fifth_boot [i: int] {
181157
assert equal $booted.image.image $"localhost/bootc-shared-($i)"
182158

183159
# Just this being booted counts as success
@@ -201,10 +177,9 @@ def main [] {
201177
"1" => second_boot,
202178
"2" => third_boot,
203179
"3" => fourth_boot,
204-
"4" => fifth_boot,
205-
"5" => { sixth_boot 1 },
206-
"6" => { sixth_boot 2 },
207-
"7" => { sixth_boot 3 },
180+
"4" => { fifth_boot 1 },
181+
"5" => { fifth_boot 2 },
182+
"6" => { fifth_boot 3 },
208183
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
209184
}
210185
}

0 commit comments

Comments
 (0)