-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathtest-composefs-gc-uki.nu
More file actions
143 lines (100 loc) · 4.12 KB
/
Copy pathtest-composefs-gc-uki.nu
File metadata and controls
143 lines (100 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# number: 41
# tmt:
# summary: Test composefs garbage collection for UKI
# duration: 30m
# extra:
# skip_if_ostree: true
use std assert
use tap.nu
if not (tap is_composefs) {
exit 0
}
# bootc status
let st = bootc status --json | from json
let booted = $st.status.booted.image
let uki_prefix = "bootc_composefs-"
let is_uki = (($st.status.booted.composefs.bootType | str downcase) == "uki")
if not $is_uki {
exit 0
}
# Create a large file in a new container image, then bootc switch to the image
def first_boot [] {
tap img_cp_to_store_smart
mut containerfile = $"
FROM localhost/bootc as base
RUN dd if=/dev/zero of=/usr/share/large-test-file bs=1k count=1337
RUN echo 'large-file-marker' | dd of=/usr/share/large-test-file conv=notrunc
"
$containerfile = (tap make_uki_containerfile $containerfile)
echo $containerfile | podman build -t localhost/bootc-first . -f -
bootc switch --transport containers-storage localhost/bootc-first
# Find the large file's verity and save it
let new_st = bootc status --json | from json
let path = bootc internals cfs dump-files $new_st.status.staged.composefs.verity /usr/share/large-test-file --backing-path-only | awk '{print $2}'
echo $"/sysroot/composefs/objects/($path)" | save /var/large-file-marker-objpath
echo $st.status.booted.composefs.verity | save /var/boot0-verity
tmt-reboot
}
# Create a container image derived from the first boot image
def second_boot [] {
mkdir /var/tmp/efi
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
assert equal $booted.image.image "localhost/bootc-first"
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot0-verity).efi" | path exists)
echo $st.status.booted.composefs.verity | save /var/boot1-verity
let path = cat /var/large-file-marker-objpath
assert ($path | path exists)
mut containerfile = echo "
FROM localhost/bootc as base
RUN echo 'second' > /usr/share/second
"
$containerfile = (tap make_uki_containerfile $containerfile)
echo $containerfile | podman build -t localhost/bootc-second . -f -
bootc switch --transport containers-storage localhost/bootc-second
tmt-reboot
}
def third_boot [] {
mkdir /var/tmp/efi
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
assert equal $booted.image.image "localhost/bootc-second"
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot0-verity).efi" | path exists))
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists)
echo $st.status.booted.composefs.verity | save /var/boot2-verity
# this is not deleted yet
let path = cat /var/large-file-marker-objpath
assert ($path | path exists)
mut containerfile = echo "
FROM localhost/bootc as base
RUN echo 'third' > /usr/share/third
"
$containerfile = (tap make_uki_containerfile $containerfile)
echo $containerfile | podman build -t localhost/bootc-third . -f -
bootc switch --transport containers-storage localhost/bootc-third
tmt-reboot
}
def fourth_boot [] {
mkdir /var/tmp/efi
mount /dev/disk/by-partlabel/EFI-SYSTEM /var/tmp/efi
assert equal $booted.image.image "localhost/bootc-third"
assert (not ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot1-verity).efi" | path exists))
assert ($"/var/tmp/efi/EFI/Linux/bootc/($uki_prefix)(cat /var/boot2-verity).efi" | path exists)
mut containerfile = "
FROM localhost/bootc as base
RUN echo 'another file' > /usr/share/another-one
"
$containerfile = (tap make_uki_containerfile $containerfile)
echo $containerfile | podman build -t localhost/bootc-final . -f -
bootc switch --transport containers-storage localhost/bootc-final
let path = cat /var/large-file-marker-objpath
assert (not ($path | path exists))
tap ok
}
def main [] {
match $env.TMT_REBOOT_COUNT? {
null | "0" => first_boot,
"1" => second_boot,
"2" => third_boot,
"3" => fourth_boot,
$o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } },
}
}