From 73e70e326c68c2cfb557f4d1f7da00fa2424ca4d Mon Sep 17 00:00:00 2001 From: codex Date: Sun, 26 Jul 2026 08:38:16 +0000 Subject: [PATCH] test(docker): wait for multitenant probe readiness --- .../integration/test_multitenant_isolation.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/integration/test_multitenant_isolation.py b/tests/integration/test_multitenant_isolation.py index 64ac9931..3d5ad717 100644 --- a/tests/integration/test_multitenant_isolation.py +++ b/tests/integration/test_multitenant_isolation.py @@ -18,6 +18,7 @@ from __future__ import annotations import secrets import subprocess +import time import unittest from bot_bottle.backend.docker.consolidated_launch import ( @@ -119,14 +120,27 @@ class TestMultitenantIsolation(unittest.TestCase): return next_free_ip(_network_cidr(GATEWAY_NETWORK), taken) def _probe(self, source_ip: str, host: str) -> str: - proc = subprocess.run( - ["docker", "run", "--rm", "--network", GATEWAY_NETWORK, "--ip", source_ip, - "--entrypoint", "python3", GATEWAY_IMAGE, "-c", _PROBE_SRC, - f"http://{self.gw_ip}:{EGRESS_PORT}", host], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, - check=False, timeout=90, + deadline = time.monotonic() + 30 + last = subprocess.CompletedProcess([], 1, "", "probe not attempted") + while time.monotonic() < deadline: + last = subprocess.run( + [ + "docker", "run", "--rm", + "--network", GATEWAY_NETWORK, "--ip", source_ip, + "--entrypoint", "python3", GATEWAY_IMAGE, "-c", _PROBE_SRC, + f"http://{self.gw_ip}:{EGRESS_PORT}", host, + ], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, + check=False, timeout=90, + ) + output = last.stdout.strip() + if last.returncode == 0 and output: + return output + time.sleep(0.25) + self.fail( + f"gateway probe did not become ready: " + f"exit={last.returncode}, stderr={last.stderr.strip()!r}" ) - return proc.stdout.strip() def test_two_bottles_share_gateway_with_isolated_tokens_and_allowlists(self) -> None: ip_a = self._free_ip([])