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

Allow fetching container info from the runner and outbound-test container #625

Merged
merged 3 commits into from
Jun 21, 2023
Merged
Changes from 1 commit
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
12 changes: 10 additions & 2 deletions goth/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from goth.assertions.monitor import Assertion, AssertionFunction, EventMonitor
from goth.runner.container.compose import (
ComposeConfig,
ContainerInfo,
ComposeNetworkManager,
run_compose_network,
)
Expand Down Expand Up @@ -69,6 +70,9 @@ class Runner:
proxy: Optional[Proxy]
"""An embedded instance of mitmproxy."""

_container_info: Dict[str, ContainerInfo]
"""Info about connected containers"""

_test_failure_callback: Callable[[TestFailure], None]
"""A function to be called when `TestFailure` is caught during a test run."""

Expand Down Expand Up @@ -114,6 +118,7 @@ def __init__(
self.api_assertions_module = api_assertions_module
self.probes = []
self.proxy = None
self._container_info = {}
self._exit_stack = AsyncExitStack()
self._cancellation_callback = cancellation_callback
self._test_failure_callback = test_failure_callback
Expand Down Expand Up @@ -171,6 +176,9 @@ def check_assertion_errors(self, *extra_monitors: EventMonitor) -> None:
# one of them to break the execution.
raise TemporalAssertionError(assertion.name)

def get_container_info(self) -> Dict[str, ContainerInfo]:
return self._container_info

def _create_probes(self, scenario_dir: Path) -> None:
docker_client = docker.from_env()

Expand Down Expand Up @@ -315,10 +323,10 @@ async def _enter(self) -> None:
self._exit_stack.enter_context(configure_logging_for_test(self.log_dir))
logger.info(colors.yellow("Running test: %s"), self.test_name)

container_info = await self._exit_stack.enter_async_context(
self._container_info = await self._exit_stack.enter_async_context(
run_compose_network(self._compose_manager, self.log_dir)
)
for info in container_info.values():
for info in self._container_info.values():
if PROXY_NGINX_SERVICE_NAME in info.aliases:
self._nginx_service_address = info.address
break
Expand Down