Skip to content

Commit

Permalink
machine_core: Check for ws-container test scenario for starting Cockpit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinpitt committed Oct 23, 2024
1 parent 2d61c4e commit 2fe590f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions machine/machine_core/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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")
Expand Down

0 comments on commit 2fe590f

Please sign in to comment.