fix(macos-container): mount live egress routes dir
This commit is contained in:
@@ -90,13 +90,40 @@ class TestApplyRoutesChange(unittest.TestCase):
|
||||
self.assertEqual("routes:\n - host: google.com\n", after)
|
||||
self.assertEqual(
|
||||
"routes:\n - host: google.com\n",
|
||||
(Path(self._tmp.name) / ".bot-bottle/state/dev/egress/egress_routes.yaml").read_text(encoding="utf-8"),
|
||||
(Path(self._tmp.name) / ".bot-bottle/state/dev/egress/routes.yaml").read_text(encoding="utf-8"),
|
||||
)
|
||||
self.assertEqual(
|
||||
["docker", "kill", "--signal", "HUP", "bot-bottle-sidecars-dev"],
|
||||
calls[0],
|
||||
)
|
||||
|
||||
def test_updates_legacy_routes_file_when_existing_bottle_mounted_it(self):
|
||||
legacy_path = (
|
||||
Path(self._tmp.name)
|
||||
/ ".bot-bottle/state/dev/egress/egress_routes.yaml"
|
||||
)
|
||||
legacy_path.parent.mkdir(parents=True)
|
||||
legacy_path.write_text("routes: []\n", encoding="utf-8")
|
||||
|
||||
with patch(
|
||||
"bot_bottle.backend.docker.egress_apply.subprocess.run",
|
||||
return_value=SimpleNamespace(returncode=0, stdout="", stderr=""),
|
||||
):
|
||||
before, after = apply_routes_change(
|
||||
"dev",
|
||||
"routes:\n - host: google.com\n",
|
||||
)
|
||||
|
||||
self.assertEqual("routes: []\n", before)
|
||||
self.assertEqual("routes:\n - host: google.com\n", after)
|
||||
self.assertEqual(
|
||||
"routes:\n - host: google.com\n",
|
||||
legacy_path.read_text(encoding="utf-8"),
|
||||
)
|
||||
self.assertFalse(
|
||||
(Path(self._tmp.name) / ".bot-bottle/state/dev/egress/routes.yaml").exists(),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -27,7 +27,7 @@ def _plan(
|
||||
agent_git_gate_url: str = "",
|
||||
agent_supervise_url: str = "",
|
||||
) -> MacosContainerBottlePlan:
|
||||
routes_path = stage_dir / "source-routes.yaml"
|
||||
routes_path = stage_dir / "routes.yaml"
|
||||
routes_path.write_text("routes: []\n", encoding="utf-8")
|
||||
ca_dir = stage_dir / "egress-ca"
|
||||
ca_dir.mkdir(exist_ok=True)
|
||||
@@ -126,7 +126,7 @@ class TestMacosContainerLaunchArgv(unittest.TestCase):
|
||||
argv,
|
||||
)
|
||||
self.assertIn(
|
||||
f"type=bind,source={self.stage_dir / 'source-routes.yaml'},target=/etc/egress/routes.yaml,readonly",
|
||||
f"type=bind,source={self.stage_dir},target=/etc/egress,readonly",
|
||||
argv,
|
||||
)
|
||||
self.assertIn(
|
||||
|
||||
Reference in New Issue
Block a user