Skip to content

Commit 22f1d9c

Browse files
authored
RHOAIENG-18459: chore(tests/containers): handle multiple podman machines and improve debugging output when podman machine is not found (#869)
* RHOAIENG-18459: chore(tests/containers): improve debugging output when podman machine is not found * RHOAIENG-18459: chore(tests/containers): reduce the number of podman machine inspect calls, by giving it all machine names at once
1 parent 9e76f6f commit 22f1d9c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tests/containers/podman_machine_utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
def open_ssh_tunnel(machine_predicate: Callable[[tests.containers.schemas.PodmanMachine], bool],
1212
local_port: int, remote_port: int, remote_interface: str = "localhost") -> subprocess.Popen:
1313
# Load and parse the Podman machine data
14-
json_data = subprocess.check_output(["podman", "machine", "inspect"], text=True)
14+
machine_names = subprocess.check_output(["podman", "machine", "list", "--quiet"], text=True).splitlines()
15+
json_data = subprocess.check_output(["podman", "machine", "inspect", *machine_names], text=True)
1516
inspect = tests.containers.schemas.PodmanMachineInspect(machines=json.loads(json_data))
1617
machines = inspect.machines
1718

1819
machine = next((m for m in machines if machine_predicate(m)), None)
1920
if not machine:
20-
raise ValueError(f"Machine matching given predicate not found")
21+
raise ValueError(f"Machine matching given predicate not found:"
22+
f" the available machines are: {machines}")
2123

2224
ssh_command = [
2325
"ssh",

tests/containers/workbenches/workbench_image_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_ipv6_only(self, image: str, test_frame):
8989
host = "localhost"
9090
port = podman_machine_utils.find_free_port()
9191
socket_path = os.path.realpath(docker_utils.get_socket_path(client.client))
92+
logging.debug(f"{socket_path=}")
9293
process = podman_machine_utils.open_ssh_tunnel(
9394
machine_predicate=lambda m: os.path.realpath(m.ConnectionInfo.PodmanSocket.Path) == socket_path,
9495
local_port=port, remote_port=container.port,

0 commit comments

Comments
 (0)