fix(ci): join control planes to the runner network
prd-number-check / require-numbered-prds (pull_request) Successful in 13s
tracker-policy-pr / check-pr (pull_request) Successful in 8s
test / integration-docker (pull_request) Failing after 35s
test / unit (pull_request) Successful in 52s
test / coverage (pull_request) Has been skipped
lint / lint (push) Successful in 1m7s
prd-number-check / require-numbered-prds (pull_request) Successful in 13s
tracker-policy-pr / check-pr (pull_request) Successful in 8s
test / integration-docker (pull_request) Failing after 35s
test / unit (pull_request) Successful in 52s
test / coverage (pull_request) Has been skipped
lint / lint (push) Successful in 1m7s
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
"""Tests for the socket-shared Docker host address helper."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from contextlib import redirect_stderr, redirect_stdout
|
||||
from io import StringIO
|
||||
from unittest.mock import patch
|
||||
|
||||
from scripts.docker_host_address import default_ipv4_gateway, main
|
||||
|
||||
|
||||
class TestDefaultIpv4Gateway(unittest.TestCase):
|
||||
def test_decodes_linux_little_endian_gateway(self) -> None:
|
||||
routes = (
|
||||
"Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n"
|
||||
"eth0 00000000 010011AC 0003 0 0 0 00000000 0 0 0\n"
|
||||
)
|
||||
self.assertEqual("172.17.0.1", default_ipv4_gateway(routes))
|
||||
|
||||
def test_rejects_table_without_default_gateway(self) -> None:
|
||||
routes = (
|
||||
"Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n"
|
||||
"eth0 000011AC 00000000 0001 0 0 0 00FFFFFF 0 0 0\n"
|
||||
)
|
||||
with self.assertRaisesRegex(ValueError, "no active"):
|
||||
default_ipv4_gateway(routes)
|
||||
|
||||
def test_ignores_short_malformed_and_inactive_routes(self) -> None:
|
||||
routes = (
|
||||
"Iface Destination Gateway Flags\n"
|
||||
"short row\n"
|
||||
"eth0 00000000 nope 0003\n"
|
||||
"eth0 00000000 010011AC 0001\n"
|
||||
)
|
||||
with self.assertRaisesRegex(ValueError, "no active"):
|
||||
default_ipv4_gateway(routes)
|
||||
|
||||
def test_main_prints_gateway(self) -> None:
|
||||
routes = (
|
||||
"Iface Destination Gateway Flags\n"
|
||||
"eth0 00000000 010011AC 0003\n"
|
||||
)
|
||||
output = StringIO()
|
||||
with patch("pathlib.Path.read_text", return_value=routes), \
|
||||
redirect_stdout(output):
|
||||
self.assertEqual(0, main())
|
||||
self.assertEqual("172.17.0.1\n", output.getvalue())
|
||||
|
||||
def test_main_reports_route_error(self) -> None:
|
||||
error = StringIO()
|
||||
with patch("pathlib.Path.read_text", side_effect=OSError("denied")), \
|
||||
redirect_stderr(error):
|
||||
self.assertEqual(1, main())
|
||||
self.assertIn("docker-host-address: denied", error.getvalue())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -69,6 +69,34 @@ class TestDockerOrchestrator(unittest.TestCase):
|
||||
root_mount_source="state-volume",
|
||||
)
|
||||
|
||||
def test_socket_shared_job_network_uses_container_dns(self) -> None:
|
||||
orch = DockerOrchestrator(
|
||||
name="orchestrator-itest",
|
||||
port=22001,
|
||||
client_network="runner-job-network",
|
||||
root_mount_source="state-volume",
|
||||
)
|
||||
with patch(_TOKEN, return_value="k"), \
|
||||
patch(
|
||||
_URLOPEN,
|
||||
side_effect=[urllib.error.URLError("down"), _health(200)],
|
||||
), patch(_RUN, return_value=_proc()) as run, patch(_SLEEP):
|
||||
orch.ensure_running()
|
||||
self.assertEqual("http://orchestrator-itest:8099", orch.url())
|
||||
calls = [call.args[0] for call in run.call_args_list]
|
||||
self.assertIn(
|
||||
[
|
||||
"docker", "network", "connect",
|
||||
"runner-job-network", "orchestrator-itest",
|
||||
],
|
||||
calls,
|
||||
)
|
||||
argv = next(call for call in calls if call[:2] == ["docker", "run"])
|
||||
self.assertEqual(
|
||||
"127.0.0.1:22001:8099",
|
||||
argv[argv.index("--publish") + 1],
|
||||
)
|
||||
|
||||
def test_gateway_url_is_the_container_dns_name(self) -> None:
|
||||
# The gateway reaches the orchestrator by name on the control network.
|
||||
self.assertEqual(f"http://{ORCHESTRATOR_NAME}:8099", self.orch.gateway_url())
|
||||
|
||||
Reference in New Issue
Block a user