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 28, 2025
1 parent 0dfb58e commit b2a67f6
Show file tree
Hide file tree
Showing 2 changed files with 45 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 -f - . <<EOF
FROM localhost:5000/bootc:latest
COPY ./rpms /tmp/rpms
RUN dnf install -y /tmp/rpms/*.rpm && dnf clean all
RUN rm -r /tmp/rpms
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
20 changes: 20 additions & 0 deletions test/image-prepare
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,24 @@ 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 ".src" not in rpm and "-debug" not in rpm:
args += ["--upload", f"{rpm}:/var/tmp/rpms/"]
args += [
"--script", os.path.join(TEST_DIR, "bootc.install"),
"--upload", os.path.join(BASE_DIR, "dist/playground") + ":/usr/local/share/cockpit/"]
return args


def build_install_container(dist_tar, image, verbose, quick):
"""Build VM with cockpit/ws container
Expand Down Expand Up @@ -253,6 +271,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 b2a67f6

Please sign in to comment.