Skip to content

Commit

Permalink
Allow fetching container info from the runner and outbound-test conta…
Browse files Browse the repository at this point in the history
…iner (#625)

* Allow fetching container info from the runner

* Add outbound-test container for test_e2e_outbound_perf

* Gr1N/setup-poetry@v7 -> v8
  • Loading branch information
kamirr committed Jun 21, 2023
1 parent 3ee6546 commit 0b3b2cc
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
python-version: '3.8'

- name: Configure poetry
uses: Gr1N/setup-poetry@v7
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.2.2

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: '3.8'

- name: Configure poetry
uses: Gr1N/setup-poetry@v7
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.2.2

Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
python-version: '3.8'

- name: Configure poetry
uses: Gr1N/setup-poetry@v7
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.2.2

Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
python-version: '3.8'

- name: Configure poetry
uses: Gr1N/setup-poetry@v7
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.2.2

Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
python-version: '3.8'

- name: Configure poetry
uses: Gr1N/setup-poetry@v7
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.2.2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version: '3.8'

- name: Configure poetry
uses: Gr1N/setup-poetry@v7
uses: Gr1N/setup-poetry@v8
with:
poetry-version: 1.2.2

Expand Down
9 changes: 9 additions & 0 deletions goth/default-assets/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ services:
- WEB3_PROVIDER_URI=http://ethereum:8545
depends_on:
- ethereum

outbound-test:
# A service running a TCP sink, echo and iperf3 servers
image: outbound-test
build:
context: .
dockerfile: ./outbound-test.Dockerfile
ports:
- "22235-22238:22235-22238"

networks:
default:
Expand Down
16 changes: 16 additions & 0 deletions goth/default-assets/docker/outbound-test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:22.04

RUN apt update \
&& apt install -y libssl-dev ca-certificates \
&& update-ca-certificates \
&& apt install -y ncat iperf3

RUN printf '#!/bin/bash \n\
ncat -e /bin/cat -k -l 22235 & \n\
ncat -l 22236 -k >/dev/null & \n\
iperf3 -p 22237 -s & \n\
while true; do sleep 1; done' >> /usr/bin/entrypoint.sh

RUN chmod +x /usr/bin/entrypoint.sh

ENTRYPOINT /usr/bin/entrypoint.sh
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

0 comments on commit 0b3b2cc

Please sign in to comment.