From f60f74b1fc002b0aa976e7c7026b7384238bdaad Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 22 Oct 2024 12:44:58 +0200 Subject: [PATCH] test: Add /container scenario This prepares an image without any cockpit packages, and with an up to date cockpit/ws container, so that all the code runs via beiboot. With this we can finally re-introduce at least some tests on RHEL 8, as that's a very interesting target for beibooting and the ws container or Cockpit Client. TODO: - hardcoded fedora-40 (FIXME) --- test/image-prepare | 32 ++++++++++++++++++++++++++++++++ test/run | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/test/image-prepare b/test/image-prepare index 1ec4c8c99177..5532e4ac27b8 100755 --- a/test/image-prepare +++ b/test/image-prepare @@ -142,6 +142,35 @@ def build_install_ostree(dist_tar, image, verbose, quick): return args +def build_install_container(dist_tar, image, verbose, quick): + """Build VM with cockpit/ws container + + This can test an image with beibooting from a cockpit/ws container, without + any installed cockpit packages. + """ + # FIXME: this needs to be the image that corresponds to the actual cockpit/ws container + # parse from containers/ws/Dockerfile + with create_machine("fedora-40") as m: + build_rpms(dist_tar, m, verbose, quick) + # copy them where ws-container.install expects them + m.execute(r"find /var/tmp/build -name '*.rpm' -not -name '*.src.rpm' -exec mv {} /var/tmp/ \;") + # create container + m.upload([os.path.join(BASE_DIR, "containers")], "/var/tmp/") + with open(os.path.join(TEST_DIR, "ws-container.install")) as f: + m.execute(f.read()) + # download container + m.execute("podman save cockpit/ws -o /var/tmp/ws.tar") + m.download("/var/tmp/ws.tar", os.path.abspath("tmp/")) + + return [ + # install container + "--upload", os.path.abspath("tmp/ws.tar") + ":/var/tmp/", + "--run-command", "podman load -i /var/tmp/ws.tar; rm /var/tmp/ws.tar", + # remove preinstalled rpms + "--run-command", "dnf -C remove -y cockpit-bridge cockpit-ws", + ] + + def validate_packages(): """Post-install package checks""" @@ -171,6 +200,7 @@ def main(): parser.add_argument('-q', '--quick', action='store_true', help='Skip unit tests to build faster') parser.add_argument('-o', '--overlay', action='store_true', help='Install into existing test/image/ overlay instead of from pristine base image') + parser.add_argument('--container', action='store_true', help='Install cockpit/ws container instead of rpms') parser.add_argument('image', nargs='?', default=DEFAULT_IMAGE, help='The image to use') args = parser.parse_args() @@ -186,6 +216,8 @@ def main(): if args.image == "fedora-coreos": customize += build_install_ostree(dist_tar, args.image, args.verbose, args.quick) + elif args.container: + customize += build_install_container(dist_tar, args.image, args.verbose, args.quick) else: customize += build_install_package(dist_tar, args.image) diff --git a/test/run b/test/run index 2907598da380..ef181f567132 100755 --- a/test/run +++ b/test/run @@ -61,6 +61,10 @@ case "${TEST_SCENARIO:=}" in *other*) RUN_OPTS="$RUN_OPTS $(echo "$ALL_TESTS" | grep -Ev "$RE_NETWORKING|$RE_STORAGE|$RE_EXPENSIVE")" ;;& + *ws-container*) + PREPARE_OPTS="$PREPARE_OPTS --quick --ws-container" + RUN_OPTS="$RUN_OPTS " + ;;& esac