From da45f6c803481286627ec0fe9a079639e2d9b8bc Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Sun, 18 Jun 2023 12:03:31 +0200 Subject: [PATCH 1/3] Allow fetching container info from the runner --- goth/runner/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/goth/runner/__init__.py b/goth/runner/__init__.py index bd49b082..2ab86585 100644 --- a/goth/runner/__init__.py +++ b/goth/runner/__init__.py @@ -25,6 +25,7 @@ from goth.assertions.monitor import Assertion, AssertionFunction, EventMonitor from goth.runner.container.compose import ( ComposeConfig, + ContainerInfo, ComposeNetworkManager, run_compose_network, ) @@ -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.""" @@ -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 @@ -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() @@ -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 From b2f0b395c717c21504f4f8b996aefa4335a4b06f Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Tue, 20 Jun 2023 10:08:13 +0200 Subject: [PATCH 2/3] Add outbound-test container for test_e2e_outbound_perf --- goth/default-assets/docker/docker-compose.yml | 9 +++++++++ .../docker/outbound-test.Dockerfile | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 goth/default-assets/docker/outbound-test.Dockerfile diff --git a/goth/default-assets/docker/docker-compose.yml b/goth/default-assets/docker/docker-compose.yml index 7c2a3a7f..9c54bcef 100644 --- a/goth/default-assets/docker/docker-compose.yml +++ b/goth/default-assets/docker/docker-compose.yml @@ -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: diff --git a/goth/default-assets/docker/outbound-test.Dockerfile b/goth/default-assets/docker/outbound-test.Dockerfile new file mode 100644 index 00000000..48c17302 --- /dev/null +++ b/goth/default-assets/docker/outbound-test.Dockerfile @@ -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 \ No newline at end of file From 866e75a0812957ff9f5155534c0e433e401dcff4 Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Tue, 20 Jun 2023 10:41:42 +0200 Subject: [PATCH 3/3] Gr1N/setup-poetry@v7 -> v8 --- .github/workflows/codestyle.yml | 2 +- .github/workflows/publish.yml | 8 ++++---- .github/workflows/unit.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index dbd13be4..bedae417 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 41a171d5..3ed8e0f0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index b0197657..d59e539d 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -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