Skip to content

Commit e4dea2b

Browse files
Johan-Liebert1cgwalters
authored andcommitted
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 0401db4 commit e4dea2b

2 files changed

Lines changed: 18 additions & 70 deletions

File tree

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

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,12 @@ def first_boot [] {
3636

3737
echo $containerfile | podman build -t localhost/bootc-first . -f -
3838

39-
let current_time = (date now)
40-
4139
bootc switch --transport containers-storage localhost/bootc-first
4240

4341
# 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
42+
let new_st = bootc status --json | from json
43+
let path = bootc internals cfs dump-files $new_st.status.staged.composefs.verity /usr/share/large-test-file --backing-path-only | awk '{print $2}'
44+
echo $"/sysroot/composefs/objects/($path)" | save /var/large-file-marker-objpath
5445

5546
echo $st.status.booted.composefs.verity | save /var/boot0-verity
5647

@@ -68,7 +59,6 @@ def second_boot [] {
6859
echo $st.status.booted.composefs.verity | save /var/boot1-verity
6960

7061
let path = cat /var/large-file-marker-objpath
71-
7262
assert ($path | path exists)
7363

7464
mut containerfile = echo "
@@ -90,7 +80,7 @@ def third_boot [] {
9080
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
9181

9282
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)
83+
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot0-verity).efi" | path exists))
9484
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists)
9585

9686
echo $st.status.booted.composefs.verity | save /var/boot2-verity
@@ -119,12 +109,9 @@ def fourth_boot [] {
119109
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
120110

121111
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)
112+
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists))
124113
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot2-verity).efi" | path exists)
125114

126-
echo $st.status.booted.composefs.verity | save /var/boot3-verity
127-
128115
mut containerfile = "
129116
FROM localhost/bootc as base
130117
RUN echo 'another file' > /usr/share/another-one
@@ -135,22 +122,10 @@ def fourth_boot [] {
135122
echo $containerfile | podman build -t localhost/bootc-final . -f -
136123

137124
bootc switch --transport containers-storage localhost/bootc-final
138-
tap ok
139-
}
140-
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"
146125

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)
152126
let path = cat /var/large-file-marker-objpath
153127
assert (not ($path | path exists))
128+
154129
tap ok
155130
}
156131

@@ -160,7 +135,6 @@ def main [] {
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: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,12 @@ def first_boot [] {
3030
RUN echo 'large-file-marker' | dd of=/usr/share/large-test-file conv=notrunc
3131
" | podman build -t localhost/bootc-derived . -f -
3232

33-
let current_time = (date now)
34-
3533
bootc switch --transport containers-storage localhost/bootc-derived
3634

3735
# 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
36+
let new_st = bootc status --json | from json
37+
let path = bootc internals cfs dump-files $new_st.status.staged.composefs.verity /usr/share/large-test-file --backing-path-only | awk '{print $2}'
38+
echo $"/sysroot/composefs/objects/($path)" | save /var/large-file-marker-objpath
4839

4940
echo $st.status.booted.composefs.verity | save /var/first-verity
5041

@@ -123,22 +114,6 @@ def third_boot [] {
123114
echo "
124115
FROM localhost/bootc-derived-initrd
125116
RUN echo 'another file' > /usr/share/another-one
126-
" | podman build -t localhost/bootc-prefinal . -f -
127-
128-
129-
bootc switch --transport containers-storage localhost/bootc-prefinal
130-
131-
tmt-reboot
132-
}
133-
134-
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
142117
" | podman build -t localhost/bootc-final . -f -
143118

144119

@@ -147,7 +122,7 @@ def fourth_boot [] {
147122
tmt-reboot
148123
}
149124

150-
def fifth_boot [] {
125+
def fourth_boot [] {
151126
let bootloader = (bootc status --json | from json).status.booted.composefs.bootloader
152127

153128
if ($bootloader | str downcase) == "systemd" {
@@ -156,10 +131,6 @@ def fifth_boot [] {
156131
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
157132
}
158133

159-
# The large file should be GC'd in the previous switch
160-
let path = cat /var/large-file-marker-objpath
161-
assert (not ($path | path exists))
162-
163134
assert equal $booted.image.image "localhost/bootc-final"
164135
assert (not ((cat /var/to-be-deleted-kernel | path exists)))
165136

@@ -174,10 +145,14 @@ def fifth_boot [] {
174145

175146
bootc switch --transport containers-storage localhost/bootc-shared-1
176147

148+
# The large file should be GC'd in the previous switch
149+
let path = cat /var/large-file-marker-objpath
150+
assert (not ($path | path exists))
151+
177152
tmt-reboot
178153
}
179154

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

183158
# Just this being booted counts as success
@@ -201,10 +176,9 @@ def main [] {
201176
"1" => second_boot,
202177
"2" => third_boot,
203178
"3" => fourth_boot,
204-
"4" => fifth_boot,
205-
"5" => { sixth_boot 1 },
206-
"6" => { sixth_boot 2 },
207-
"7" => { sixth_boot 3 },
179+
"4" => { fifth_boot 1 },
180+
"5" => { fifth_boot 2 },
181+
"6" => { fifth_boot 3 },
208182
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
209183
}
210184
}

0 commit comments

Comments
 (0)