|
| 1 | +# number: 46 |
| 2 | +# tmt: |
| 3 | +# summary: Verify etc merge conflicts are caught during upgrade, not finalization |
| 4 | +# duration: 15m |
| 5 | +# |
| 6 | +# Verifies that file-to-directory and directory-to-file type changes between |
| 7 | +# the current /etc and the new image's /etc are detected during `bootc switch` |
| 8 | +# (the upgrade phase) and cause it to fail immediately, rather than silently |
| 9 | +# staging and failing during finalization at reboot. |
| 10 | +# |
| 11 | +# No reboot needed: the upgrade is expected to fail before staging. |
| 12 | +use std assert |
| 13 | +use tap.nu |
| 14 | + |
| 15 | +if not (tap is_composefs) { |
| 16 | + exit 0 |
| 17 | +} |
| 18 | + |
| 19 | +tap begin "etc merge conflict detection during upgrade" |
| 20 | + |
| 21 | +def main [] { |
| 22 | + bootc image copy-to-storage |
| 23 | + |
| 24 | + # Test case 1: File in current /etc conflicts with directory in new image's /etc. |
| 25 | + # Create a file on the live system; the new image will have a directory at |
| 26 | + # the same path. |
| 27 | + "local modification" | save /etc/test-etc-merge-conflict |
| 28 | + |
| 29 | + let td = mktemp -d |
| 30 | + cd $td |
| 31 | + |
| 32 | + let dockerfile = ' |
| 33 | +FROM localhost/bootc as base |
| 34 | +RUN mkdir -p /etc/test-etc-merge-conflict && \ |
| 35 | + echo "inner" > /etc/test-etc-merge-conflict/inner.conf |
| 36 | +' |
| 37 | + (tap make_uki_containerfile $dockerfile) | save Dockerfile |
| 38 | + podman build -t localhost/bootc-etc-conflict . |
| 39 | + |
| 40 | + let result = do { bootc switch --transport containers-storage localhost/bootc-etc-conflict } | complete |
| 41 | + print $"exit_code: ($result.exit_code)" |
| 42 | + print $"stderr: ($result.stderr)" |
| 43 | + |
| 44 | + assert ($result.exit_code != 0) "bootc switch should fail: locally-added file conflicts with directory in new etc" |
| 45 | + assert ($result.stderr | str contains "Merge conflicts found in etc") $"Expected 'Merge conflicts found in etc' in stderr, got: ($result.stderr)" |
| 46 | + |
| 47 | + # Verify no deployment was staged - the failure must happen during upgrade, |
| 48 | + # not during finalization at reboot. |
| 49 | + assert ((bootc status --json | from json | get status.staged) == null) "No deployment should be staged after merge conflict failure" |
| 50 | + |
| 51 | + # Test case 2: Directory in current /etc conflicts with file in new image's /etc. |
| 52 | + # Create a directory with a file inside on the live system; the new image |
| 53 | + # will have a regular file at the same path. |
| 54 | + mkdir /etc/test-etc-merge-dir |
| 55 | + "local config" | save /etc/test-etc-merge-dir/local.conf |
| 56 | + |
| 57 | + let td2 = mktemp -d |
| 58 | + cd $td2 |
| 59 | + |
| 60 | + let dockerfile2 = ' |
| 61 | +FROM localhost/bootc as base |
| 62 | +RUN echo "now a file" > /etc/test-etc-merge-dir |
| 63 | +' |
| 64 | + (tap make_uki_containerfile $dockerfile2) | save Dockerfile |
| 65 | + podman build -t localhost/bootc-etc-conflict-2 . |
| 66 | + |
| 67 | + let result2 = do { bootc switch --transport containers-storage localhost/bootc-etc-conflict-2 } | complete |
| 68 | + print $"exit_code: ($result2.exit_code)" |
| 69 | + print $"stderr: ($result2.stderr)" |
| 70 | + |
| 71 | + assert ($result2.exit_code != 0) "bootc switch should fail: locally-added directory conflicts with file in new etc" |
| 72 | + assert ($result2.stderr | str contains "Merge conflicts found in etc") $"Expected 'Merge conflicts found in etc' in stderr, got: ($result2.stderr)" |
| 73 | + |
| 74 | + # Again verify nothing was staged |
| 75 | + assert ((bootc status --json | from json | get status.staged) == null) "No deployment should be staged after directory-to-file conflict failure" |
| 76 | + |
| 77 | + tap ok |
| 78 | +} |
0 commit comments