-
Notifications
You must be signed in to change notification settings - Fork 168
tmt: Add bootc-image-builder integration test for issue #1907 #1922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cgwalters
wants to merge
1
commit into
bootc-dev:main
Choose a base branch
from
cgwalters:bib-check
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+134
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # number: 33 | ||
| # tmt: | ||
| # summary: Test building a qcow2 disk image with bootc-image-builder | ||
| # duration: 45m | ||
| # require: | ||
| # - qemu-img | ||
| # | ||
| # This test validates that bootc-image-builder (bib) can successfully | ||
| # create disk images from the current booted image. This is a critical | ||
| # integration test to catch regressions like: | ||
| # https://github.com/bootc-dev/bootc/issues/1907 | ||
| # | ||
| # The key scenario tested here is a partition layout where /boot is a | ||
| # directory on the root filesystem (NOT a separate partition), but | ||
| # /boot/efi IS a separate mount point. The bug was that when bootc | ||
| # checked /boot, it found "efi" as a directory entry and failed to | ||
| # recognize it was actually a mount point on a different device. | ||
| # | ||
| use std assert | ||
| use tap.nu | ||
|
|
||
| const BIB_IMAGE = "quay.io/centos-bootc/bootc-image-builder:latest" | ||
|
|
||
| def main [] { | ||
| tap begin "bootc-image-builder qcow2 build test" | ||
|
|
||
| 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 | ||
|
|
||
| # Verify the image is in storage | ||
| let images = podman images --format json | from json | ||
| let bootc_img = $images | where Names != null | where { |img| | ||
| $img.Names | any { |t| $t == "localhost/bootc:latest" } | ||
| } | ||
| assert (($bootc_img | length) > 0) "Expected localhost/bootc image in podman storage" | ||
|
|
||
| # Build a derived image that: | ||
| # 1. Removes bound images (bib runs isolated) | ||
| # 2. Embeds a disk.yaml that creates a layout WITHOUT a separate /boot partition | ||
| # This triggers the bug from issue #1907 where /boot is a directory on root | ||
| # and /boot/efi is a mount point | ||
| print "=== Building derived image with no-/boot-partition layout ===" | ||
| 'FROM localhost/bootc | ||
| RUN rm -rf /usr/lib/bootc/bound-images.d/* | ||
| RUN mkdir -p /usr/lib/bootc-image-builder && cat > /usr/lib/bootc-image-builder/disk.yaml << "DISKEOF" | ||
| # Partition layout without a separate /boot partition. | ||
| # This mimics the CentOS Automotive ukiboot layout and triggers issue #1907. | ||
| # The key is that /boot is a directory on root, but /boot/efi is a mount point. | ||
| .common: | ||
| partitioning: | ||
| guids: | ||
| - &bios_boot_partition_guid "21686148-6449-6E6F-744E-656564454649" | ||
| - &efi_system_partition_guid "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" | ||
| - &filesystem_data_guid "0FC63DAF-8483-4772-8E79-3D69D8477DE4" | ||
|
|
||
| partition_table: | ||
| type: "gpt" | ||
| partitions: | ||
| - size: "1 MiB" | ||
| bootable: true | ||
| type: *bios_boot_partition_guid | ||
| - size: "501 MiB" | ||
| type: *efi_system_partition_guid | ||
| payload_type: "filesystem" | ||
| payload: | ||
| type: vfat | ||
| mountpoint: "/boot/efi" | ||
| label: "EFI-SYSTEM" | ||
| fstab_options: "umask=0077,shortname=winnt" | ||
| fstab_freq: 0 | ||
| fstab_passno: 2 | ||
| - size: "4 GiB" | ||
| type: *filesystem_data_guid | ||
| payload_type: "filesystem" | ||
| payload: | ||
| type: xfs | ||
| label: "root" | ||
| mountpoint: "/" | ||
| fstab_options: "ro" | ||
| DISKEOF | ||
| ' | save Dockerfile | ||
| podman build -t localhost/bootc-bib-test . | ||
|
|
||
| # Create output directory for bib | ||
| mkdir output | ||
|
|
||
| # Run bootc-image-builder to create a qcow2 | ||
| # We use --local to pull from local containers-storage | ||
| # The embedded disk.yaml will be used for partitioning | ||
| print "=== Running bootc-image-builder ===" | ||
| 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 --local localhost/bootc-bib-test | ||
cgwalters marked this conversation as resolved.
Show resolved
Hide resolved
cgwalters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Verify output was created | ||
| print "=== Verifying output ===" | ||
| let disk_path = "output/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) | ||
| # Note: qcow2 files are sparse, so file size != virtual size | ||
| # We use qemu-img to get the actual virtual disk size | ||
| let info = qemu-img info --output=json $disk_path | from json | ||
| let virtual_size = $info | get virtual-size | ||
| print $"Disk image virtual size: ($virtual_size | into filesize)" | ||
| # The disk.yaml specifies ~4.5 GiB total, so virtual size should be at least 4 GiB | ||
| assert ($virtual_size > 4000000000) "Disk image virtual size seems too small" | ||
|
|
||
| # Also print file size for reference (qcow2 is sparse/compressed) | ||
| let file_size = ls $disk_path | get size | first | ||
| print $"Disk image file size: ($file_size)" | ||
|
|
||
| print "=== Success: bootc-image-builder created disk image ===" | ||
| tap ok | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.