Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHOAIENG-18459: chore(tests/containers): handle multiple podman machines and improve debugging output when podman machine is not found #869

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/containers/podman_machine_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
def open_ssh_tunnel(machine_predicate: Callable[[tests.containers.schemas.PodmanMachine], bool],
local_port: int, remote_port: int, remote_interface: str = "localhost") -> subprocess.Popen:
# Load and parse the Podman machine data
json_data = subprocess.check_output(["podman", "machine", "inspect"], text=True)
machine_names = subprocess.check_output(["podman", "machine", "list", "--quiet"], text=True).splitlines()
json_data = subprocess.check_output(["podman", "machine", "inspect", *machine_names], text=True)
inspect = tests.containers.schemas.PodmanMachineInspect(machines=json.loads(json_data))
machines = inspect.machines

machine = next((m for m in machines if machine_predicate(m)), None)
if not machine:
raise ValueError(f"Machine matching given predicate not found")
raise ValueError(f"Machine matching given predicate not found:"
f" the available machines are: {machines}")

ssh_command = [
"ssh",
Expand Down
1 change: 1 addition & 0 deletions tests/containers/workbenches/workbench_image_test.py
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/override ci/prow/images
n/a

Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_ipv6_only(self, image: str, test_frame):
host = "localhost"
port = podman_machine_utils.find_free_port()
socket_path = os.path.realpath(docker_utils.get_socket_path(client.client))
logging.debug(f"{socket_path=}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - are we keeping this on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise the exception after podman machine was not found (that may be printed later) is meaningless. This writes down the socket it was looking for.

process = podman_machine_utils.open_ssh_tunnel(
machine_predicate=lambda m: os.path.realpath(m.ConnectionInfo.PodmanSocket.Path) == socket_path,
local_port=port, remote_port=container.port,
Expand Down
Loading