Skip to content

Commit fe824d5

Browse files
committed
tests: Add integration test for ukiboot with install to-disk
Exercise the native aboot installer through the existing bcvk and TMT runner on x86_64. Derive the image from the OSTree test rootfs so backend selection must follow the boot artifact, and verify the default disk layout, both payload slots, and boot completion. After that we try an update and rollback. Note: This manually installs bcvk 0.21.0, this can be dropped once bootc-dev/actions has been updated. Generated-by: AI Signed-off-by: Alexander Larsson <alexl@redhat.com>
1 parent e582abb commit fe824d5

12 files changed

Lines changed: 298 additions & 2 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,51 @@ jobs:
655655
name: container-export-test-${{ env.ARCH }}
656656
path: target/anaconda-test/*.log
657657

658+
test-ukiboot:
659+
if: needs.compute-ci-level.outputs.run_heavy == 'true' && contains(fromJson(needs.compute-ci-level.outputs.package_os_matrix), 'fedora-44')
660+
needs: [compute-ci-level, package]
661+
runs-on: ubuntu-26.04
662+
env:
663+
BOOTC_base: quay.io/fedora/fedora-bootc:44
664+
BOOTC_buildroot_base: quay.io/fedora/fedora:44
665+
BOOTC_variant: ostree
666+
BOOTC_SKIP_PACKAGE: "1"
667+
steps:
668+
- uses: actions/checkout@v7
669+
- name: Bootc Ubuntu Setup
670+
uses: bootc-dev/actions/bootc-ubuntu-setup@main
671+
with:
672+
libvirt: true
673+
- name: Install bcvk with aboot support
674+
# Temporary: Drop once bootc-dev/actions has 0.21.0 or later
675+
run: |
676+
set -euo pipefail
677+
# renovate: datasource=github-releases depName=bootc-dev/bcvk
678+
version=0.21.0
679+
target=bcvk-x86_64-unknown-linux-gnu
680+
td=$(mktemp -d)
681+
curl -fL --retry 5 --retry-delay 10 "https://github.com/bootc-dev/bcvk/releases/download/v${version}/${target}.tar.gz" -o "$td/bcvk.tar.gz"
682+
tar -xzf "$td/bcvk.tar.gz" -C "$td"
683+
sudo install -m 0755 "$td/$target" /usr/local/bin/bcvk
684+
bcvk --version
685+
- name: Install tmt
686+
uses: ./.github/actions/install-tmt
687+
- name: Download package artifacts
688+
uses: actions/download-artifact@v8
689+
with:
690+
name: packages-fedora-44
691+
path: target/packages/
692+
- name: Fetch external dependencies
693+
run: just build-fetch
694+
- name: Install, update, and roll back ukiboot image
695+
run: just test-ukiboot
696+
- name: Archive test logs
697+
if: always()
698+
uses: actions/upload-artifact@v7
699+
with:
700+
name: ukiboot-test-x86_64
701+
path: /var/tmp/tmt
702+
658703
# Gates the full heavy suite. Runs in merge_group / workflow_dispatch, and
659704
# also directly on PRs whenever compute-ci-level found no merge queue
660705
# active (see the merge-queue check in that job) — in that case a PR is
@@ -666,7 +711,7 @@ jobs:
666711
# rather than being skipped along with it.
667712
required-checks-heavy:
668713
if: ${{ always() && (github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && needs.compute-ci-level.outputs.merge_queue_enabled != 'true')) }}
669-
needs: [compute-ci-level, cargo-deny, validate, install-tests, docs, package, test-integration, test-upgrade, test-baseconfigs, test-container-export]
714+
needs: [compute-ci-level, cargo-deny, validate, install-tests, docs, package, test-integration, test-upgrade, test-baseconfigs, test-container-export, test-ukiboot]
670715
# Cheap aggregation (jq only) — no need for a full VM.
671716
runs-on: ubuntu-slim
672717
steps:

‎Justfile‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ base_img := env("BOOTC_image", "localhost/bootc")
3333
upgrade_img := base_img + "-upgrade"
3434
# Base image with tmt dependencies added, used as the boot source for upgrade tests
3535
upgrade_source_img := base_img + "-upgrade-source"
36+
ukiboot_img := base_img + "-ukiboot"
3637

3738
# Build variant: ostree (default) or composefs
3839
variant := env("BOOTC_variant", "ostree")
@@ -192,6 +193,18 @@ test-tmt *ARGS: build
192193
@just _build-upgrade-image
193194
@just test-tmt-nobuild {{ARGS}}
194195

196+
[group('testing')]
197+
build-ukiboot-test-image: build
198+
podman build {{_nocache_arg}} --build-arg=base={{base_img}} -f tmt/tests/Dockerfile.ukiboot -t {{ukiboot_img}}:v1 .
199+
200+
[group('testing')]
201+
build-ukiboot-update-test-image: build-ukiboot-test-image
202+
podman build {{_nocache_arg}} --build-arg=base={{base_img}} --build-arg=TEST_VERSION=2 -f tmt/tests/Dockerfile.ukiboot -t {{ukiboot_img}}:v2 .
203+
204+
[group('testing')]
205+
test-ukiboot: build-ukiboot-update-test-image
206+
cargo xtask run-tmt --env=BOOTC_variant=composefs --filesystem=ext4 --boot-type=aboot --seal-state=unsealed --upgrade-image={{ukiboot_img}}:v2 {{ukiboot_img}}:v1 aboot
207+
195208
# Split out from `test-container` because, unlike the container integration tests,
196209
# unit tests don't depend on variant/filesystem/bootloader/boot_type/seal_state, so
197210
# CI runs this once per OS (in the `package` job) instead of once per test-integration

‎crates/xtask/src/xtask.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,16 @@ pub enum BootType {
205205
Bls,
206206
/// UKI boot
207207
Uki,
208+
/// Aboot boot
209+
Aboot,
208210
}
209211

210212
impl Display for BootType {
211213
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
212214
match self {
213215
BootType::Bls => f.write_str("bls"),
214216
BootType::Uki => f.write_str("uki"),
217+
BootType::Aboot => f.write_str("aboot"),
215218
}
216219
}
217220
}
@@ -310,7 +313,7 @@ pub(crate) struct RunTmtArgs {
310313
#[arg(long, env = "BOOTC_seal_state")]
311314
pub(crate) seal_state: Option<SealState>,
312315

313-
/// Boot entry type (bls or uki)
316+
/// Boot entry type (bls, uki, or aboot)
314317
#[arg(long, env = "BOOTC_boot_type", default_value_t)]
315318
pub(crate) boot_type: BootType,
316319

‎tmt/plans/integration.fmf‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,29 @@ execute:
367367
test:
368368
- /tmt/tests/tests/test-60-install-composefs-native
369369
extra-fixme_skip_if_uki: true
370+
371+
/plan-61-aboot-install:
372+
summary: Test artifact-selected ukiboot installation
373+
enabled: false
374+
discover:
375+
how: fmf
376+
test:
377+
- /tmt/tests/tests/test-61-aboot-install
378+
adjust:
379+
- when: boot_type == aboot
380+
enabled: true
381+
extra-skip_if_ostree: true
382+
383+
/plan-62-aboot-update-rollback:
384+
summary: Test ukiboot A/B update and rollback
385+
enabled: false
386+
discover:
387+
how: fmf
388+
test:
389+
- /tmt/tests/tests/test-62-aboot-update-rollback
390+
adjust:
391+
- when: boot_type == aboot
392+
enabled: true
393+
extra-try_bind_storage: true
394+
extra-skip_if_ostree: true
370395
# END GENERATED PLANS

‎tmt/tests/Dockerfile.ukiboot‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ARG base=localhost/bootc
2+
FROM ${base} AS rootfs
3+
COPY tmt/tests/ukiboot/aboot.cfg /etc/aboot.cfg
4+
COPY tmt/tests/ukiboot/kargs.toml /usr/lib/bootc/kargs.d/90-ukiboot.toml
5+
RUN --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
6+
dnf -y --setopt=install_weak_deps=False install aboot-deploy aboot-update ukiboot systemd-ukify systemd-boot && \
7+
dnf clean all && rm -rf /var/cache /var/log /var/lib/dnf && \
8+
rm -rf /etc/repart.d /run/repart.d /usr/lib/repart.d /usr/local/lib/repart.d /usr/lib/bootc/bound-images.d && \
9+
systemctl enable ukiboot-set-success.service
10+
ARG TEST_VERSION=1
11+
RUN --network=none printf '%s\n' "${TEST_VERSION}" > /usr/share/bootc-aboot-test-version
12+
13+
FROM rootfs AS split
14+
RUN --network=none mkdir -p /boot/.kernel && \
15+
bootc container split-kernel-and-rootfs --rootfs / --output /boot/.kernel
16+
17+
FROM scratch AS flattened
18+
COPY --from=split / /
19+
20+
FROM rootfs AS aboot
21+
RUN --network=none --mount=type=bind,from=flattened,source=/,target=/target,ro <<'EOF'
22+
set -eux
23+
kver=$(ls /target/boot/.kernel)
24+
mkdir -p /out
25+
bootc container aboot --rootfs /target --kernel-dir "/target/boot/.kernel/${kver}" --out /out --allow-missing-verity
26+
test -s "/out/aboot-${kver}.img"
27+
EOF
28+
29+
FROM flattened
30+
RUN --network=none rm -rf /boot/.kernel
31+
COPY --from=aboot /out/ /boot/
32+
LABEL containers.bootc="1"
33+
CMD ["/sbin/init"]
34+
RUN --network=none bootc container lint --skip nonempty-boot --fatal-warnings
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!tmt/tests/ukiboot/

‎tmt/tests/booted/aboot_testlib.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import json
2+
from pathlib import Path
3+
import re
4+
import subprocess
5+
import time
6+
7+
8+
def run(*args):
9+
return subprocess.check_output(args, text=True).strip()
10+
11+
12+
def status():
13+
return json.loads(run("bootc", "status", "--json"))["status"]
14+
15+
16+
def verify_boot(slot, version):
17+
assert run("systemctl", "is-enabled", "ukiboot-set-success.service") == "enabled"
18+
for service in ("ukiboot-set-success.service", "bootc-aboot-reconcile.service"):
19+
for attempt in range(60):
20+
active = run("systemctl", "show", "--property=ActiveState", "--value", service)
21+
assert active != "failed", service
22+
if active == "active":
23+
break
24+
time.sleep(1)
25+
else:
26+
raise AssertionError(f"{service} did not finish at boot")
27+
assert run("systemctl", "show", "--property=Result", "--value", service) == "success"
28+
st = status()
29+
booted = st["booted"]
30+
assert booted["ostree"] is None, booted
31+
assert booted["composefs"]["bootType"] == "Aboot", booted
32+
assert run("findmnt", "--noheadings", "--output", "FSTYPE", "--target", "/sysroot") == "ext4"
33+
assert st["staged"] is None, st
34+
assert not st["rollbackQueued"], st
35+
assert Path("/usr/share/bootc-aboot-test-version").read_text().strip() == str(version)
36+
assert f"androidboot.slot_suffix=_{slot}" in Path("/proc/cmdline").read_text().split()
37+
mapping = Path(f"/sysroot/state/boot/aboot/slots/{slot}").read_text().strip()
38+
assert mapping == booted["composefs"]["verity"], (mapping, booted)
39+
control = run("ukibootctl", "dump")
40+
print(control)
41+
slot_number = {"a": 0, "b": 1}[slot]
42+
assert re.search(rf"^Slot {slot_number}: .*successful_boot: 1$", control, re.MULTILINE), control
43+
return st
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# number: 61
2+
# tmt:
3+
# summary: Test artifact-selected ukiboot installation
4+
# duration: 30m
5+
# enabled: false
6+
# adjust:
7+
# - when: boot_type == aboot
8+
# enabled: true
9+
# extra:
10+
# skip_if_ostree: true
11+
12+
import hashlib
13+
import json
14+
from pathlib import Path
15+
16+
from aboot_testlib import run, verify_boot
17+
18+
19+
def main():
20+
print("TAP version 14\nukiboot installation and boot")
21+
verify_boot("a", 1)
22+
root_disk = Path("/dev/disk/by-partlabel/root-x86-64").resolve()
23+
parent = run("lsblk", "--noheadings", "--output", "PKNAME", str(root_disk))
24+
table = json.loads(run("sfdisk", "--json", f"/dev/{parent}"))["partitiontable"]
25+
parts = table["partitions"]
26+
expected = {
27+
"esp": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
28+
"ukiboot_a": "df331e4d-be00-463f-b4a7-8b43e18fb53a",
29+
"ukiboot_b": "df331e4d-be00-463f-b4a7-8b43e18fb53a",
30+
"ukibootctl": "fefd9070-346f-4c9a-85e6-17f07f922773",
31+
"root-x86-64": "4f68bce3-e8cd-4db1-96e7-fbcaf984b709",
32+
}
33+
assert len(parts) == len(expected), parts
34+
assert {p["name"]: p["type"].lower() for p in parts} == expected, parts
35+
payloads = []
36+
for slot in ("a", "b"):
37+
part = next(p for p in parts if p["name"] == f"ukiboot_{slot}")
38+
assert part["size"] * table["sectorsize"] == 192 * 1024 * 1024, part
39+
with open(f"/dev/disk/by-partlabel/ukiboot_{slot}", "rb") as payload:
40+
assert payload.read(2) == b"MZ"
41+
payload.seek(0)
42+
payloads.append(hashlib.file_digest(payload, "sha256").hexdigest())
43+
assert payloads[0] == payloads[1], payloads
44+
esp = Path(run("findmnt", "--noheadings", "--output", "TARGET", "--source", "/dev/disk/by-partlabel/esp"))
45+
assert (esp / "EFI/BOOT/BOOTX64.EFI").is_file()
46+
for slot in ("a", "b"):
47+
assert list(esp.glob(f"EFI/*/ukiboot_{slot}.efi.extra.d/slot_{slot}.addon.efi"))
48+
print("ok 1 - ukiboot installation and boot")
49+
50+
51+
if __name__ == "__main__":
52+
main()
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# number: 62
2+
# tmt:
3+
# summary: Test ukiboot A/B update and rollback
4+
# duration: 30m
5+
# enabled: false
6+
# adjust:
7+
# - when: boot_type == aboot
8+
# enabled: true
9+
# extra:
10+
# skip_if_ostree: true
11+
# try_bind_storage: true
12+
13+
import json
14+
import os
15+
from pathlib import Path
16+
import subprocess
17+
18+
from aboot_testlib import run, status, verify_boot
19+
20+
ORIGINAL = Path("/var/tmp/bootc-aboot-original.json")
21+
22+
23+
def main():
24+
print("TAP version 14\nukiboot update and rollback")
25+
count = int(os.environ.get("TMT_REBOOT_COUNT", "0"))
26+
target = os.environ["BOOTC_upgrade_image"]
27+
if count == 0:
28+
initial = verify_boot("a", 1)
29+
ORIGINAL.write_text(json.dumps(initial["booted"]))
30+
run("bootc", "switch", "--transport", "containers-storage", target)
31+
staged = status()
32+
assert staged["booted"] == initial["booted"], staged
33+
assert staged["staged"]["image"]["image"]["image"] == target, staged
34+
assert staged["staged"]["composefs"]["bootType"] == "Aboot", staged
35+
assert staged["staged"]["composefs"]["verity"] != initial["booted"]["composefs"]["verity"], staged
36+
subprocess.run(["tmt-reboot"], check=True)
37+
elif count == 1:
38+
original = json.loads(ORIGINAL.read_text())
39+
updated = verify_boot("b", 2)
40+
assert updated["booted"]["image"]["image"]["image"] == target, updated
41+
assert updated["booted"]["composefs"]["verity"] != original["composefs"]["verity"], updated
42+
assert updated["rollback"]["image"] == original["image"], updated
43+
assert updated["rollback"]["composefs"]["verity"] == original["composefs"]["verity"], updated
44+
run("bootc", "rollback")
45+
assert status()["rollbackQueued"]
46+
subprocess.run(["tmt-reboot"], check=True)
47+
elif count == 2:
48+
original = json.loads(ORIGINAL.read_text())
49+
restored = verify_boot("a", 1)
50+
assert restored["booted"]["image"] == original["image"], restored
51+
assert restored["booted"]["composefs"]["verity"] == original["composefs"]["verity"], restored
52+
ORIGINAL.unlink()
53+
print("ok 1 - ukiboot A/B update and rollback")
54+
else:
55+
raise AssertionError(f"Unexpected reboot count {count}")
56+
57+
58+
if __name__ == "__main__":
59+
main()

‎tmt/tests/tests.fmf‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,21 @@ check:
233233
summary: Test that composefs-native images default to the composefs backend
234234
duration: 45m
235235
test: nu booted/test-install-composefs-native.nu
236+
237+
/test-61-aboot-install:
238+
summary: Test artifact-selected ukiboot installation
239+
duration: 30m
240+
enabled: false
241+
adjust:
242+
- when: boot_type == aboot
243+
enabled: true
244+
test: python3 booted/test-aboot-install.py
245+
246+
/test-62-aboot-update-rollback:
247+
summary: Test ukiboot A/B update and rollback
248+
duration: 30m
249+
enabled: false
250+
adjust:
251+
- when: boot_type == aboot
252+
enabled: true
253+
test: python3 booted/test-aboot-update-rollback.py

0 commit comments

Comments
 (0)