test(docker): wait for multitenant probe readiness
prd-number-check / require-numbered-prds (pull_request) Successful in 6s
tracker-policy-pr / check-pr (pull_request) Successful in 26s
test / unit (pull_request) Successful in 49s
lint / lint (push) Successful in 59s
test / integration-docker (pull_request) Failing after 1m1s
test / coverage (pull_request) Has been skipped
prd-number-check / require-numbered-prds (pull_request) Successful in 6s
tracker-policy-pr / check-pr (pull_request) Successful in 26s
test / unit (pull_request) Successful in 49s
lint / lint (push) Successful in 59s
test / integration-docker (pull_request) Failing after 1m1s
test / coverage (pull_request) Has been skipped
This commit is contained in:
@@ -18,6 +18,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import secrets
|
import secrets
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bot_bottle.backend.docker.consolidated_launch import (
|
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)
|
return next_free_ip(_network_cidr(GATEWAY_NETWORK), taken)
|
||||||
|
|
||||||
def _probe(self, source_ip: str, host: str) -> str:
|
def _probe(self, source_ip: str, host: str) -> str:
|
||||||
proc = subprocess.run(
|
deadline = time.monotonic() + 30
|
||||||
["docker", "run", "--rm", "--network", GATEWAY_NETWORK, "--ip", source_ip,
|
last = subprocess.CompletedProcess([], 1, "", "probe not attempted")
|
||||||
"--entrypoint", "python3", GATEWAY_IMAGE, "-c", _PROBE_SRC,
|
while time.monotonic() < deadline:
|
||||||
f"http://{self.gw_ip}:{EGRESS_PORT}", host],
|
last = subprocess.run(
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,
|
[
|
||||||
check=False, timeout=90,
|
"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:
|
def test_two_bottles_share_gateway_with_isolated_tokens_and_allowlists(self) -> None:
|
||||||
ip_a = self._free_ip([])
|
ip_a = self._free_ip([])
|
||||||
|
|||||||
Reference in New Issue
Block a user