Skip to content

test: add integration tests for 'bootc switch --apply' #1420

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

p5
Copy link
Contributor

@p5 p5 commented Jul 17, 2025

I've not had chance to setup a local environment for tmt, so hoping I'm able to test in this PR.

This uses the existing test-20-local-upgrade.fmf with a lot of the unneeded tests stripped out. Might move this into that test, we'll see.

If all goes well, tests will fail to begin with. Then when I rebase the fixes, they pass.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new integration test for bootc switch --apply. The test creates a derived container image, switches to it, and verifies the system reboots into the new image with the correct kernel arguments.

The changes are logical and well-structured. I've found a critical issue with a filename typo in one of the tmf files that would prevent the test from running. I've also pointed out a few minor improvements in the nushell test script, such as removing unused variables and an unnecessary bash -c wrapper to improve code clarity and maintainability.

Once these points are addressed, the new test will be a valuable addition to the test suite.

@p5 p5 force-pushed the systemd-run-reboot-test branch from b975721 to 06725a3 Compare July 17, 2025 12:26
@p5
Copy link
Contributor Author

p5 commented Jul 17, 2025

Hmm. Reading the docs, it doesn't seem like tmt supports rebooting using anything other than the tmt-reboot command. Or if it does, it won't increment the TMT_REBOOT_COUNT variable.

Will rebase to the fix, just in case it happens to work as I expect. Though I doubt it.

@p5 p5 closed this Jul 17, 2025
@cgwalters
Copy link
Collaborator

Hmm. Reading the docs, it doesn't seem like tmt supports rebooting using anything other than the tmt-reboot command. Or if it does, it won't increment the TMT_REBOOT_COUNT variable.

Yes see #1419

@henrywang henrywang reopened this Jul 23, 2025
@henrywang
Copy link
Collaborator

henrywang commented Jul 23, 2025

Hi @p5,
I reopen this PR to add test for --apply. I added my research in #1419.

I can't push to your rsturla/bootc.git repository due to permission error. Could you please help to update the test-image-upgrade-reboot.nu. This should work. Thanks!

diff --git i/tmt/tests/booted/test-image-upgrade-reboot.nu w/tmt/tests/booted/test-image-upgrade-reboot.nu
index e4e8498..6c5ff5a 100644
--- i/tmt/tests/booted/test-image-upgrade-reboot.nu
+++ w/tmt/tests/booted/test-image-upgrade-reboot.nu
@@ -39,7 +39,7 @@ COPY usr/ /usr/
     podman build -t localhost/bootc-derived .
 
     # Now, switch into the new image
-    bootc switch --apply --transport containers-storage localhost/bootc-derived
+    tmt-reboot -c "bootc switch --apply --transport containers-storage localhost/bootc-derived"
 
     # We cannot perform any other checks here since the system will be automatically rebooted
 }

@p5 p5 force-pushed the systemd-run-reboot-test branch from 06725a3 to 25d7d49 Compare July 23, 2025 08:27
@p5
Copy link
Contributor Author

p5 commented Jul 23, 2025

Thanks for the pointer @henrywang !

Your patch has been applied and squashed into the existing commit. The integration tests seemingly are passing, so think this is ready for some reviews!

This test should:

  1. boot into a VM
  2. create a new image with kargs changes
  3. switch into the new image with the --apply flag
  4. verify kargs changes persisted

Edit: I'm not actually sure that this is working as we intended.
This branch is prior to the fixes in #1417, so I would expect the builds to be failing until we rebased. Looking into it.

@p5 p5 marked this pull request as ready for review July 23, 2025 09:43
@p5 p5 marked this pull request as draft July 23, 2025 09:49
podman build -t localhost/bootc-derived .

# Now, switch into the new image
tmt-reboot -c "bootc switch --apply --transport containers-storage localhost/bootc-derived"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to work - perhaps TMT reboots at the end of the command if the command itself doesn't?

Maybe we do something like:

tmt-reboot -c "bootc switch --apply --transport containers-storage localhost/bootc-derived && exit 1"

In theory, if the --apply flag works, the exit 1 should never be reached and the tests continue as expected.
If the exit 1 is hit, it should mean --apply didn't initiate a reboot, and the test will rightfully fail.

Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants