Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
867 changes: 623 additions & 244 deletions crates/xtask/src/tmt.rs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions tmt/plans/integration.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ execute:
how: fmf
test:
- /tmt/tests/tests/test-35-composefs-gc
extra-skip_if_ostree: true
extra-fixme_skip_if_uki: true

/plan-35-upgrade-preflight-disk-check:
summary: Verify pre-flight disk space check rejects images with inflated layer sizes
Expand Down Expand Up @@ -254,6 +256,7 @@ execute:
how: fmf
test:
- /tmt/tests/tests/test-41-composefs-gc-uki
extra-skip_if_ostree: true

/plan-42-loader-entries-source:
summary: Test bootc loader-entries set-options-for-source
Expand All @@ -269,6 +272,7 @@ execute:
how: fmf
test:
- /tmt/tests/tests/test-43-switch-same-digest
extra-skip_if_ostree: true

/plan-44-shadow-fixup:
summary: Test bootc-sysusers-shadow-sync removes orphaned gshadow entries before sysusers
Expand Down
12 changes: 12 additions & 0 deletions tmt/tests/booted/tap.nu
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,15 @@ export def make_uki_containerfile [containerfile: string] {

return $"($containerfile)\n($uki_stuff)"
}

# 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
export def img_cp_to_store_smart [] {
let podman_digest = (podman image inspect localhost/bootc) | jq -r '.[0].Digest'
let bootc_digest = (bootc status --json | from json).status.booted.image.imageDigest

if ($podman_digest != $bootc_digest) {
bootc image copy-to-storage
}
}
12 changes: 8 additions & 4 deletions tmt/tests/booted/test-bib-build.nu
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ const BIB_IMAGE = "quay.io/centos-bootc/bootc-image-builder:latest"
def main [] {
tap begin "bootc-image-builder qcow2 build test"

print ">>>>>>>>>>>>>>>>>> the current working directory <<<<<<<<<<<<<<<<<" ($env.PWD)

let td = mktemp -d
cd $td

# Copy the currently booted image to podman storage
print "=== Copying booted image to containers-storage ==="
bootc image copy-to-storage
tap img_cp_to_store_smart

# Verify the image is in storage
let images = podman images --format json | from json
Expand Down Expand Up @@ -87,8 +89,10 @@ DISKEOF
' | save Dockerfile
podman build -t localhost/bootc-bib-test .

let output_dir = "/var/output"

# Create output directory for bib
mkdir output
mkdir $output_dir

# Run bootc-image-builder to create a qcow2
# We use --local to pull from local containers-storage
Expand All @@ -97,11 +101,11 @@ DISKEOF
let bib_image = $BIB_IMAGE
# Note: we disable SELinux labeling since we're running in a test VM
# and use unconfined_t to avoid permission issues
podman run --rm --privileged -v /var/lib/containers/storage:/var/lib/containers/storage --security-opt label=type:unconfined_t -v ./output:/output $bib_image --type qcow2 --rootfs xfs localhost/bootc-bib-test
podman run --rm --privileged -v /var/lib/containers/storage:/var/lib/containers/storage --security-opt label=type:unconfined_t -v $"($output_dir):/output" $bib_image --type qcow2 --rootfs xfs localhost/bootc-bib-test

# Verify output was created
print "=== Verifying output ==="
let disk_path = "output/qcow2/disk.qcow2"
let disk_path = $"($output_dir)/qcow2/disk.qcow2"
assert ($disk_path | path exists) $"Expected disk image at ($disk_path)"

# Check the disk has reasonable virtual size (at least 4GB as per disk.yaml)
Expand Down
4 changes: 3 additions & 1 deletion tmt/tests/booted/test-composefs-gc-uki.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# tmt:
# summary: Test composefs garbage collection for UKI
# duration: 30m
# extra:
# skip_if_ostree: true

use std assert
use tap.nu
Expand All @@ -24,7 +26,7 @@ if not $is_uki {

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

mut containerfile = $"
FROM localhost/bootc as base
Expand Down
5 changes: 4 additions & 1 deletion tmt/tests/booted/test-composefs-gc.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# tmt:
# summary: Test composefs garbage collection with same and different kernel+initrd
# duration: 30m
# extra:
# skip_if_ostree: true
# fixme_skip_if_uki: true

use std assert
use tap.nu
Expand All @@ -22,7 +25,7 @@ if ($st.status.booted.composefs.bootType | str downcase) == "uki" {

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

echo $"
FROM localhost/bootc
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-custom-selinux-policy.nu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initial_build [] {
let td = mktemp -d
cd $td

bootc image copy-to-storage
tap img_cp_to_store_smart

# A simple derived container that customizes selinux policy for random dir
"FROM localhost/bootc
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-download-only-upgrade.nu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def initial_build [] {
# This test only works in local mode
assert ($imgsrc | str ends-with "-local") "This test requires local mode"

bootc image copy-to-storage
tap img_cp_to_store_smart

# Create test file v1 on host
"v1" | save testing-bootc-upgrade-apply
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-image-pushpull-upgrade.nu
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initial_build [] {
let td = mktemp -d
cd $td

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

mkdir usr/lib/bootc/kargs.d
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-image-upgrade-reboot.nu
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def initial_build [] {
let imgsrc = imgsrc
# For the packit case, we build locally right now
if ($imgsrc | str ends-with "-local") {
bootc image copy-to-storage
tap img_cp_to_store_smart

# A simple derived container that adds a file
(
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-install-bootloader-none.nu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def main [] {
tap begin "install with --bootloader=none"

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

truncate -s 10G disk.img
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-install-no-boot-dir.nu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def main [] {
tap begin "install to-filesystem without /boot"

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

mkdir /var/mnt
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-install-outside-container.nu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tap.nu
# EFI update metadata. Export to OCI layout on a writable path since
# containers-storage: transport can't work when the root fs is read-only
# (composefs), and install-outside-container tests run directly on the host.
bootc image copy-to-storage
tap img_cp_to_store_smart
skopeo copy containers-storage:localhost/bootc oci:/var/tmp/bootc-oci
let target_image = "oci:/var/tmp/bootc-oci"

Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-loader-entries-source.nu
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def fifth_boot [] {
# Build a derived image and switch to it (this stages a deployment).
# Then call set-options-for-source on top. The staged deployment should
# be replaced with one that has the new image AND the source kargs.
bootc image copy-to-storage
tap img_cp_to_store_smart

let td = mktemp -d
$"FROM localhost/bootc
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-logically-bound-switch.nu
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let booted = $st.status.booted.image
echo '{}' | save -f /run/ostree/auth.json

def initial_setup [] {
bootc image copy-to-storage
tap img_cp_to_store_smart
podman images
podman image inspect localhost/bootc | from json
}
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-multi-device-esp.nu
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def run_install [mountpoint: string] {
def test_single_esp [] {
tap begin "multi-device ESP detection tests"

bootc image copy-to-storage
tap img_cp_to_store_smart

print "Starting single ESP test"

Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-rollback.nu
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initial_switch [] {
let imgsrc = imgsrc

if ($imgsrc | str ends-with "-local") {
bootc image copy-to-storage
tap img_cp_to_store_smart

print "Building derived container"
let dockerfile = $"FROM localhost/bootc as base
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-soft-reboot-selinux-policy.nu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def initial_build [] {
let td = mktemp -d
cd $td

bootc image copy-to-storage
tap img_cp_to_store_smart

# copy-to-storage does not copy repo file
# but OSCI gating test needs repo to install package
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-soft-reboot.nu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initial_build [] {
let td = mktemp -d
cd $td

bootc image copy-to-storage
tap img_cp_to_store_smart

# A simple derived container that adds a file, but also injects some kargs
let dockerfile = $"FROM localhost/bootc as base
Expand Down
4 changes: 3 additions & 1 deletion tmt/tests/booted/test-switch-same-digest.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# tmt:
# summary: Error on bootc switch to image with identical fs-verity digest
# duration: 10m
# extra:
# skip_if_ostree: true
#
# Verify that `bootc switch` errors out when the target image produces the
# same composefs fs-verity digest as an existing deployment. The simplest
Expand All @@ -17,7 +19,7 @@ if not (tap is_composefs) {
tap begin "bootc switch to same-digest image must error"

# Copy the booted image into podman storage so we can retag it.
bootc image copy-to-storage
tap img_cp_to_store_smart

# Tag the same image under a second name — identical bits, so the composefs
# EROFS digest will be the same as the currently booted deployment.
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-switch-to-unified.nu
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def first_boot [] {
tap begin "copy image to podman storage, switch, then onboard to unified storage"

# Copy the currently booted image to podman storage
bootc image copy-to-storage
tap img_cp_to_store_smart

# Switch to the base image using containers-storage transport
bootc switch --transport containers-storage localhost/bootc
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-upgrade-check-status.nu
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def imgsrc [] {
def initial_build [] {
tap begin "upgrade --check cached update in status"

bootc image copy-to-storage
tap img_cp_to_store_smart

# A simple derived container that adds a file with a version label
"FROM localhost/bootc
Expand Down
2 changes: 1 addition & 1 deletion tmt/tests/booted/test-upgrade-tag.nu
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initial_build [] {
cd $td

# Copy bootc image to local storage
bootc image copy-to-storage
tap img_cp_to_store_smart

# Build v1 image
let dockerfile = $"FROM localhost/bootc as base
Expand Down
Loading