From 2fe590f997a5b17b6671a672b013cf52522114d9 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 23 Oct 2024 09:16:28 +0200 Subject: [PATCH] machine_core: Check for ws-container test scenario for starting Cockpit We want to test the cockpit/ws container with beibooting on other images than just OSTree. Tests currently check the `Machine.ostree_image` flag both for *actual* specifics of OSTree (such as a read-only /usr) as well as a proxy for "am I running Cockpit from the container". As this won't coincide in the future, introduce a new `Machine.ws_container` flag. Set this for OSTree images, but also if the test scenario contains "ws-container". This keeps the choice explicit, and thus the tests robust. --- machine/machine_core/machine.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/machine/machine_core/machine.py b/machine/machine_core/machine.py index fc5b2b6c3..068c006f2 100644 --- a/machine/machine_core/machine.py +++ b/machine/machine_core/machine.py @@ -89,6 +89,9 @@ def __init__( self.arch = arch self.image = image self.ostree_image = self.image in OSTREE_IMAGES + # start via cockpit/ws container on OSTree or when explicitly requested + self.ws_container = self.ostree_image or "ws-container" in os.getenv("TEST_SCENARIO", "") + if ":" in browser: self.web_address, _, self.web_port = browser.rpartition(":") else: @@ -250,8 +253,7 @@ def start_cockpit(self, *, tls: bool = False) -> None: Cockpit is not running when the test virtual machine starts up, to allow you to make modifications before it starts. """ - - if self.ostree_image: + if self.ws_container: self.stop_cockpit() cmd = "podman container runlabel RUN cockpit/ws" if not tls: @@ -284,7 +286,7 @@ def start_cockpit(self, *, tls: bool = False) -> None: def restart_cockpit(self) -> None: """Restart Cockpit. """ - if self.ostree_image: + if self.ws_container: self.execute(f"podman restart {self.get_cockpit_container()}") self.wait_for_cockpit_running() else: @@ -293,7 +295,7 @@ def restart_cockpit(self) -> None: def stop_cockpit(self) -> None: """Stop Cockpit. """ - if self.ostree_image: + if self.ws_container: self.execute(f"echo {self.get_cockpit_container()} | xargs --no-run-if-empty podman rm -f") else: self.execute("systemctl stop cockpit.socket cockpit.service")