test: add integration tests for 'bootc switch --apply'#1420
test: add integration tests for 'bootc switch --apply'#1420cgwalters merged 1 commit intobootc-dev:mainfrom rsturla:systemd-run-reboot-test
Conversation
There was a problem hiding this comment.
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.
|
Hmm. Reading the docs, it doesn't seem like tmt supports rebooting using anything other than the
|
Yes see #1419 |
|
Hi @p5, I can't push to your 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
} |
|
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:
Edit: I'm not actually sure that this is working as we intended. |
|
Hi @p5, can we land this PR? Thanks. |
I'm honestly not sure that we would want to... My view is this current PR gives a false sense of security that the The purpose is to ensure |
|
I think the |
Ah, right. I didn't realise that was the case. Will mark this ready to review. |
Wait I don't think that's true. How could that be? It's the same code being invoked...unless it somehow theoretically related to being invoked inside or outside of a systemd unit but I don't think that's the case. |
One possibility is that the packit testing flow is defaulting to rebasing the PR on main? I mean, we can find out for sure if we're having a "false test pass" by pushing a commit which explicitly breaks the functionality into this PR. |
| bootc image copy-to-storage | ||
|
|
||
| mkdir usr/lib/bootc/kargs.d | ||
| { kargs: $kargsv0 } | to toml | save usr/lib/bootc/kargs.d/05-testkargs.toml |
There was a problem hiding this comment.
For this test, I think using kernel arguments is a bit of a distraction. We already have coverage of kernel arguments in the original test this was copied from. It seems simpler to just create some new content e.g. touch /usr/share/testing-bootc-upgrade-apply or something and verify that file exists.
(This would also mean this test would automatically get optimized a bit with soft reboots in the future)
There was a problem hiding this comment.
Once the tests complete, will add the following:
commit 913b199ab92c78c5d8f27dec36f41a6eb6bc8d06 (HEAD -> systemd-run-reboot-test)
Author: Robert Sturla <robertsturla@outlook.com>
Date: Wed Jul 30 20:41:03 2025 +0100
chore: verify file is present in newer deployment
Signed-off-by: Robert Sturla <robertsturla@outlook.com>
diff --git a/tmt/tests/booted/test-image-upgrade-reboot.nu b/tmt/tests/booted/test-image-upgrade-reboot.nu
index 5d7b9bc3..31dda7a5 100644
--- a/tmt/tests/booted/test-image-upgrade-reboot.nu
+++ b/tmt/tests/booted/test-image-upgrade-reboot.nu
@@ -7,8 +7,6 @@
use std assert
use tap.nu
-const kargsv0 = ["testarg=foo", "othertestkarg", "thirdkarg=bar"]
-
# This code runs on *each* boot.
# Here we just capture information.
bootc status
@@ -28,11 +26,9 @@ def initial_build [] {
bootc image copy-to-storage
- mkdir usr/lib/bootc/kargs.d
- { kargs: $kargsv0 } | to toml | save usr/lib/bootc/kargs.d/05-testkargs.toml
- # A simple derived container that adds a file, but also injects some kargs
+ # A simple derived container that adds a file
"FROM localhost/bootc
-COPY usr/ /usr/
+RUN touch /usr/share/testing-bootc-upgrade-apply
" | save Dockerfile
# Build it
podman build -t localhost/bootc-derived .
@@ -49,13 +45,8 @@ def second_boot [] {
assert equal $booted.image.transport containers-storage
assert equal $booted.image.image localhost/bootc-derived
- # Verify we have updated kargs
- let cmdline = parse_cmdline
- print $"cmdline=($cmdline)"
- for x in $kargsv0 {
- print $"Verifying karg ($x)"
- assert ($x in $cmdline)
- }
+ # Verify the new file exists
+ "/usr/share/testing-bootc-upgrade-apply" | path exists
tap ok
Uses https://www.nushell.sh/commands/docs/path_exists.html to check if the file exists
|
There's another possibility, which is that I tried to trace through the code, it's "complicated". Clicking on tmt-reboot-core shows that internally it writes the command to be executed as JSON into a file found by an environment variable |
|
(Those folks who know me know I'm really a strong "dynamic languages are only suitable for toy projects" person, and yeah, jinja2 to template shell script from python is like three whole levels of dynamism...) |
Yep I was right, check out the RPM build logs: it now directly fails because of a conflict. |
Signed-off-by: Robert Sturla <robertsturla@outlook.com>
Ah, that answers it then! That's why the tests never failed where I expected them to! Though I can't say I'm too keen on the hidden behaviour 🤷 I've squashed the commits, rebased on latest upstream/main, removed the debug commit and implemented the changes suggested above. The tests should pass and should be ready for a review! Thanks for the help both! |
cgwalters
left a comment
There was a problem hiding this comment.
Thank you so much for doing this and especially your careful attention to consideration as to the test unexpectedly passing!
|
Is it normal for these tests to take 2 hours? Or has my change stalled them? |
Testing Farm is outage according to https://status.testing-farm.io/. :( |
|
Hi @cgwalters, I tried on |
This uses the existing
test-20-local-upgrade.fmfwith a lot of the unneeded tests stripped out.It builds a bootc OCI image, switches into it with an
--applyflag and validates both a reboot occurred, and that kargs from the new image are applied.