|
| 1 | +# This test does: |
| 2 | +# bootc image copy-to-storage |
| 3 | +# podman build <from that image> |
| 4 | +# bootc switch <into that image> --apply |
| 5 | +# Verify we boot into the new image |
| 6 | +# |
| 7 | +use std assert |
| 8 | +use tap.nu |
| 9 | + |
| 10 | +# This code runs on *each* boot. |
| 11 | +# Here we just capture information. |
| 12 | +bootc status |
| 13 | +let st = bootc status --json | from json |
| 14 | +let booted = $st.status.booted.image |
| 15 | + |
| 16 | +# Parse the kernel commandline into a list. |
| 17 | +# This is not a proper parser, but good enough |
| 18 | +# for what we need here. |
| 19 | +def parse_cmdline [] { |
| 20 | + open /proc/cmdline | str trim | split row " " |
| 21 | +} |
| 22 | + |
| 23 | +# Run on the first boot |
| 24 | +def initial_build [] { |
| 25 | + tap begin "local image push + pull + upgrade" |
| 26 | + |
| 27 | + bootc image copy-to-storage |
| 28 | + |
| 29 | + # A simple derived container that adds a file |
| 30 | + "FROM localhost/bootc |
| 31 | +RUN touch /usr/share/testing-bootc-upgrade-apply |
| 32 | +" | save Dockerfile |
| 33 | + # Build it |
| 34 | + podman build -t localhost/bootc-derived . |
| 35 | + |
| 36 | + # Now, switch into the new image |
| 37 | + tmt-reboot -c "bootc switch --apply --transport containers-storage localhost/bootc-derived" |
| 38 | + |
| 39 | + # We cannot perform any other checks here since the system will be automatically rebooted |
| 40 | +} |
| 41 | + |
| 42 | +# Check we have the updated image |
| 43 | +def second_boot [] { |
| 44 | + print "verifying second boot" |
| 45 | + assert equal $booted.image.transport containers-storage |
| 46 | + assert equal $booted.image.image localhost/bootc-derived |
| 47 | + |
| 48 | + # Verify the new file exists |
| 49 | + "/usr/share/testing-bootc-upgrade-apply" | path exists |
| 50 | + |
| 51 | + tap ok |
| 52 | +} |
| 53 | + |
| 54 | +def main [] { |
| 55 | + # See https://tmt.readthedocs.io/en/stable/stories/features.html#reboot-during-test |
| 56 | + match $env.TMT_REBOOT_COUNT? { |
| 57 | + null | "0" => initial_build, |
| 58 | + "1" => second_boot, |
| 59 | + $o => { error make { msg: $"Invalid TMT_REBOOT_COUNT ($o)" } }, |
| 60 | + } |
| 61 | +} |
0 commit comments