Skip to content

Commit 3069761

Browse files
committed
tests: Change the upgrade test to support fetching from host
This ensures it all can work much more elegantly/naturally with sealed UKI builds - we don't want to do the build-on-target thing. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 50d0143 commit 3069761

File tree

4 files changed

+50
-19
lines changed

4 files changed

+50
-19
lines changed

Justfile

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
# --------------------------------------------------------------------
1313

14+
# This image is just the base image plus our updated bootc binary
15+
base_img := "localhost/bootc"
16+
# Derives from the above and adds nushell, cloudinit etc.
17+
integration_img := base_img + "-integration"
18+
# Has a synthetic upgrade
19+
integration_upgrade_img := integration_img + "-upgrade"
20+
1421
# ostree: The default
1522
# composefs-sealeduki-sdboot: A system with a sealed composefs using systemd-boot
1623
variant := env("BOOTC_variant", "ostree")
@@ -33,8 +40,8 @@ buildargs := "--build-arg=base=" + base + " --build-arg=variant=" + variant
3340
# Note commonly you might want to override the base image via e.g.
3441
# `just build --build-arg=base=quay.io/fedora/fedora-bootc:42`
3542
build:
36-
podman build {{base_buildargs}} -t localhost/bootc-bin {{buildargs}} .
37-
./tests/build-sealed {{variant}} localhost/bootc-bin localhost/bootc
43+
podman build {{base_buildargs}} -t {{base_img}}-bin {{buildargs}} .
44+
./tests/build-sealed {{variant}} {{base_img}}-bin {{base_img}}
3845

3946
# Build a sealed image from current sources.
4047
build-sealed:
@@ -66,8 +73,8 @@ package: _packagecontainer
6673

6774
# This container image has additional testing content and utilities
6875
build-integration-test-image: build
69-
cd hack && podman build {{base_buildargs}} -t localhost/bootc-integration-bin -f Containerfile .
70-
./tests/build-sealed {{variant}} localhost/bootc-integration-bin localhost/bootc-integration
76+
cd hack && podman build {{base_buildargs}} -t {{integration_img}}-bin -f Containerfile .
77+
./tests/build-sealed {{variant}} {{integration_img}}-bin {{integration_img}}
7178
# Keep these in sync with what's used in hack/lbi
7279
podman pull -q --retry 5 --retry-delay 5s quay.io/curl/curl:latest quay.io/curl/curl-base:latest registry.access.redhat.com/ubi9/podman:latest
7380

@@ -76,17 +83,17 @@ test-composefs:
7683
# These first two are currently a distinct test suite from tmt that directly
7784
# runs an integration test binary in the base image via bcvk
7885
just variant=composefs-sealeduki-sdboot build
79-
cargo run --release -p tests-integration -- composefs-bcvk localhost/bootc
86+
cargo run --release -p tests-integration -- composefs-bcvk {{base_img}}
8087
# We're trying to move more testing to tmt, so
8188
just variant=composefs-sealeduki-sdboot test-tmt readonly
8289

8390
# Only used by ci.yml right now
8491
build-install-test-image: build-integration-test-image
85-
cd hack && podman build {{base_buildargs}} -t localhost/bootc-integration-install -f Containerfile.drop-lbis
92+
cd hack && podman build {{base_buildargs}} -t {{integration_img}}-install -f Containerfile.drop-lbis
8693

8794
# These tests accept the container image as input, and may spawn it.
8895
run-container-external-tests:
89-
./tests/container/run localhost/bootc
96+
./tests/container/run {{base_img}}
9097

9198
# We build the unit tests into a container image
9299
build-units:
@@ -101,8 +108,18 @@ validate:
101108
#
102109
# To run an individual test, pass it as an argument like:
103110
# `just test-tmt readonly`
104-
test-tmt *ARGS: build-integration-test-image
105-
cargo xtask run-tmt --env=BOOTC_variant={{variant}} localhost/bootc-integration {{ARGS}}
111+
test-tmt *ARGS: build-integration-test-image _build-upgrade-image
112+
@just test-tmt-nobuild {{ARGS}}
113+
114+
# Generate a local synthetic upgrade
115+
_build-upgrade-image:
116+
podman build -t {{integration_upgrade_img}}-bin --from={{integration_img}}-bin -f tmt/tests/Dockerfile.upgrade /usr/share/empty
117+
./tests/build-sealed {{variant}} {{integration_upgrade_img}}-bin {{integration_upgrade_img}}
118+
119+
# Assume the localhost/bootc-integration image is up to date, and just run tests.
120+
# Useful for iterating on tests quickly.
121+
test-tmt-nobuild *ARGS:
122+
cargo xtask run-tmt --env=BOOTC_variant={{variant}} --env=BOOTC_upgrade_image={{integration_upgrade_img}} {{integration_img}} {{ARGS}}
106123

107124
# Cleanup all test VMs created by tmt tests
108125
tmt-vm-cleanup:
@@ -112,7 +129,7 @@ tmt-vm-cleanup:
112129
test-container: build-units build-integration-test-image
113130
podman run --rm --read-only localhost/bootc-units /usr/bin/bootc-units
114131
# Pass these through for cross-checking
115-
podman run --rm --env=BOOTC_variant={{variant}} --env=BOOTC_base={{base}} localhost/bootc-integration bootc-integration-tests container
132+
podman run --rm --env=BOOTC_variant={{variant}} --env=BOOTC_base={{base}} {{integration_img}} bootc-integration-tests container
116133

117134
# Remove all container images built (locally) via this Justfile, by matching a label
118135
clean-local-images:

crates/xtask/src/tmt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const COMMON_INST_ARGS: &[&str] = &[
1818
// TODO: Pass down the Secure Boot keys for tests if present
1919
"--firmware=uefi-insecure",
2020
"--label=bootc.test=1",
21+
"--bind-storage-ro",
2122
];
2223

2324
// Import the argument types from xtask.rs

tmt/tests/Dockerfile.upgrade

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Just creates a file as a new layer for a synthetic upgrade test
2+
FROM localhost/bootc-integration
3+
RUN touch --reference=/usr/bin/bash /usr/share/testing-bootc-upgrade-apply

tmt/tests/booted/test-image-upgrade-reboot.nu

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use tap.nu
1515
# This code runs on *each* boot.
1616
# Here we just capture information.
1717
bootc status
18+
journalctl --list-boots
19+
1820
let st = bootc status --json | from json
1921
let booted = $st.status.booted.image
2022

@@ -25,30 +27,38 @@ def parse_cmdline [] {
2527
open /proc/cmdline | str trim | split row " "
2628
}
2729

30+
def imgsrc [] {
31+
$env.BOOTC_upgrade_image? | default "localhost/bootc-derived-local"
32+
}
33+
2834
# Run on the first boot
2935
def initial_build [] {
3036
tap begin "local image push + pull + upgrade"
3137

32-
bootc image copy-to-storage
38+
let imgsrc = imgsrc
39+
# For the packit case, we build locally right now
40+
if ($imgsrc | str ends-with "-local") {
41+
bootc image copy-to-storage
3342

34-
# A simple derived container that adds a file
35-
"FROM localhost/bootc
43+
# A simple derived container that adds a file
44+
"FROM localhost/bootc
3645
RUN touch /usr/share/testing-bootc-upgrade-apply
3746
" | save Dockerfile
38-
# Build it
39-
podman build -t localhost/bootc-derived .
47+
# Build it
48+
podman build -t $imgsrc .
49+
}
4050

4151
# Now, switch into the new image
42-
tmt-reboot -c "bootc switch --apply --transport containers-storage localhost/bootc-derived"
43-
44-
# We cannot perform any other checks here since the system will be automatically rebooted
52+
print $"Applying ($imgsrc)"
53+
bootc switch --transport containers-storage ($imgsrc)
54+
tmt-reboot
4555
}
4656

4757
# Check we have the updated image
4858
def second_boot [] {
4959
print "verifying second boot"
5060
assert equal $booted.image.transport containers-storage
51-
assert equal $booted.image.image localhost/bootc-derived
61+
assert equal $booted.image.image $"(imgsrc)"
5262

5363
# Verify the new file exists
5464
"/usr/share/testing-bootc-upgrade-apply" | path exists

0 commit comments

Comments
 (0)