Skip to content

Commit

Permalink
test: Add bootc image preparation
Browse files Browse the repository at this point in the history
We want to test deploying cockpit rpms in bootc images. This will
prevent hiccups like
cockpit-project#21201 in the future
and also test a lot of OS subsystems.

The centos-9-bootc bots image includes its own deployment container
image, so we can easily derive an image with our locally built RPMs
included.

https://issues.redhat.com/browse/COCKPIT-1237
  • Loading branch information
martinpitt committed Jan 29, 2025
1 parent a7af6d8 commit 837aaf1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/bootc.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
set -eux

cd /var/tmp/

# bootc images have their own deployed image in a local registry
podman run -d --rm --name ostree-registry -p 5000:5000 -v /var/lib/cockpit-test-registry/:/var/lib/registry localhost/test-registry

# build updated bootc image with our RPMs
podman build -t localhost/bootc-test --layers=false -f - . <<EOF
FROM localhost:5000/bootc:latest
COPY ./rpms /tmp/rpms
RUN rpm --upgrade --verbose /tmp/rpms/*.rpm && rm -r /tmp/rpms
COPY ./playground /usr/share/cockpit/playground
EOF

# deploy it
bootc switch --transport containers-storage localhost/bootc-test

# clean up
podman rm -ft0 ostree-registry
podman rmi localhost:5000/bootc localhost/bootc-test

# ensure that we don't accidentally test with container
podman rmi quay.io/cockpit/ws:latest
21 changes: 21 additions & 0 deletions test/image-prepare
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ def build_install_ostree(dist_tar, image, verbose, quick):
return args


def build_install_bootc(dist_tar, image, verbose, quick):
"""Special treatment of build/install on Bootc
bootc image can't build packages, build them on corresponding OSes, build a new bootc
image with the rpms, and deploy it.
"""
with create_machine(testmap.get_build_image(image)) as machine:
rpms = build_rpms(dist_tar, machine, verbose, quick)
args = ["--run-command", "mkdir -p /var/tmp/rpms"]
for rpm in rpms:
if not any(r in rpm for r in [".src", "debug", "packagekit", "storaged"]):
args += ["--upload", f"{rpm}:/var/tmp/rpms/"]
args += [
"--upload", os.path.join(BASE_DIR, "dist/playground") + ":/var/tmp/playground",
"--script", os.path.join(TEST_DIR, "bootc.install"),
]
return args


def build_install_container(dist_tar, image, verbose, quick):
"""Build VM with cockpit/ws container
Expand Down Expand Up @@ -253,6 +272,8 @@ def main():

if args.image == "fedora-coreos":
customize += build_install_ostree(dist_tar, args.image, args.verbose, args.quick)
if args.image.endswith("-bootc"):
customize += build_install_bootc(dist_tar, args.image, args.verbose, args.quick)
elif args.container:
customize += build_install_container(dist_tar, args.image, args.verbose, args.quick)
else:
Expand Down

0 comments on commit 837aaf1

Please sign in to comment.