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 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 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