Skip to content

Commit df41589

Browse files
test: Check image before running bootc image copy-to-storage
We share host container storage in the VM, so we usually already have localhost/bootc as an image in the VM. If we don't find it, only then do we copy from ostree/composefs storage Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 821a82a commit df41589

21 files changed

Lines changed: 32 additions & 20 deletions

tmt/tests/booted/tap.nu

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,15 @@ export def make_uki_containerfile [containerfile: string] {
112112

113113
return $"($containerfile)\n($uki_stuff)"
114114
}
115+
116+
# We share host container storage in the VM, so we usually already have localhost/bootc
117+
# as an image in the VM. If we don't find it, only then do we copy from ostree/composefs
118+
# storage
119+
export def img_cp_to_store_smart [] {
120+
let podman_digest = (podman image inspect localhost/bootc) | jq -r '.[0].Digest'
121+
let bootc_digest = (bootc status --json | from json).status.booted.image.imageDigest
122+
123+
if ($podman_digest != $bootc_digest) {
124+
bootc image copy-to-storage
125+
}
126+
}

tmt/tests/booted/test-bib-build.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def main [] {
3131

3232
# Copy the currently booted image to podman storage
3333
print "=== Copying booted image to containers-storage ==="
34-
bootc image copy-to-storage
34+
tap img_cp_to_store_smart
3535

3636
# Verify the image is in storage
3737
let images = podman images --format json | from json

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if not $is_uki {
2424

2525
# Create a large file in a new container image, then bootc switch to the image
2626
def first_boot [] {
27-
bootc image copy-to-storage
27+
tap img_cp_to_store_smart
2828

2929
mut containerfile = $"
3030
FROM localhost/bootc as base

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if ($st.status.booted.composefs.bootType | str downcase) == "uki" {
2222

2323
# Create a large file in a new container image, then bootc switch to the image
2424
def first_boot [] {
25-
bootc image copy-to-storage
25+
tap img_cp_to_store_smart
2626

2727
echo $"
2828
FROM localhost/bootc

tmt/tests/booted/test-custom-selinux-policy.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def initial_build [] {
2424
let td = mktemp -d
2525
cd $td
2626

27-
bootc image copy-to-storage
27+
tap img_cp_to_store_smart
2828

2929
# A simple derived container that customizes selinux policy for random dir
3030
"FROM localhost/bootc

tmt/tests/booted/test-download-only-upgrade.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def initial_build [] {
4040
# This test only works in local mode
4141
assert ($imgsrc | str ends-with "-local") "This test requires local mode"
4242

43-
bootc image copy-to-storage
43+
tap img_cp_to_store_smart
4444

4545
# Create test file v1 on host
4646
"v1" | save testing-bootc-upgrade-apply

tmt/tests/booted/test-image-pushpull-upgrade.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def initial_build [] {
3939
let td = mktemp -d
4040
cd $td
4141

42-
bootc image copy-to-storage
42+
tap img_cp_to_store_smart
4343
let img = podman image inspect localhost/bootc | from json
4444

4545
mkdir usr/lib/bootc/kargs.d

tmt/tests/booted/test-image-upgrade-reboot.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def initial_build [] {
4646
let imgsrc = imgsrc
4747
# For the packit case, we build locally right now
4848
if ($imgsrc | str ends-with "-local") {
49-
bootc image copy-to-storage
49+
tap img_cp_to_store_smart
5050

5151
# A simple derived container that adds a file
5252
(

tmt/tests/booted/test-install-bootloader-none.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def main [] {
1010
tap begin "install with --bootloader=none"
1111

1212
# Copy the booted image to container storage for use as install source
13-
bootc image copy-to-storage
13+
tap img_cp_to_store_smart
1414
let target_image = "containers-storage:localhost/bootc"
1515

1616
truncate -s 10G disk.img

tmt/tests/booted/test-install-no-boot-dir.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def main [] {
1010
tap begin "install to-filesystem without /boot"
1111

1212
# Copy the booted image to container storage for use as install source
13-
bootc image copy-to-storage
13+
tap img_cp_to_store_smart
1414
let target_image = "containers-storage:localhost/bootc"
1515

1616
mkdir /var/mnt

0 commit comments

Comments
 (0)