9c4400cce2
libkrun limits total mounts + port-mappings to 5. With all three sidecar daemons active (egress, git-gate, supervise), the prior layout used 3 mounts + 3 ports = 6, causing the VM to crash at boot with krun_start_enter returned -22. Merge the egress confdir and git-gate scripts into a single staging directory mounted at /bot-bottle-data/ with egress/ and git-gate/ subdirectories, reducing to 2 mounts + 3 ports = 5. Also clean up leftover VMs before creating new ones to handle interrupted teardowns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from bot_bottle.backend.egress_apply import EgressApplyError
|
|
from bot_bottle.backend.smolmachines import egress_apply
|
|
from bot_bottle.backend.smolmachines.smolvm import SmolvmRunResult
|
|
|
|
|
|
class TestFetchCurrentRoutes(unittest.TestCase):
|
|
def test_reads_routes_from_sidecar_vm(self):
|
|
with patch.object(
|
|
egress_apply._smolvm,
|
|
"machine_exec",
|
|
return_value=SmolvmRunResult(0, "routes", ""),
|
|
) as exec_:
|
|
self.assertEqual("routes", egress_apply.fetch_current_routes("dev-abc"))
|
|
exec_.assert_called_once_with(
|
|
"bot-bottle-sidecars-dev-abc",
|
|
["cat", "/bot-bottle-data/egress/routes.yaml"],
|
|
)
|
|
|
|
def test_read_failure_raises_apply_error(self):
|
|
with patch.object(
|
|
egress_apply._smolvm,
|
|
"machine_exec",
|
|
return_value=SmolvmRunResult(1, "", "nope"),
|
|
):
|
|
with self.assertRaises(EgressApplyError):
|
|
egress_apply.fetch_current_routes("dev-abc")
|
|
|
|
|
|
class TestReload(unittest.TestCase):
|
|
def test_sends_hup_to_sidecar_init(self):
|
|
with patch.object(
|
|
egress_apply._smolvm,
|
|
"machine_exec",
|
|
return_value=SmolvmRunResult(0, "", ""),
|
|
) as exec_:
|
|
egress_apply.SmolmachinesEgressApplicator()._signal_bundle_reload("dev-abc")
|
|
exec_.assert_called_once_with(
|
|
"bot-bottle-sidecars-dev-abc",
|
|
["sh", "-c", "kill -HUP 1"],
|
|
)
|
|
|
|
def test_reload_failure_raises_apply_error(self):
|
|
with patch.object(
|
|
egress_apply._smolvm,
|
|
"machine_exec",
|
|
return_value=SmolvmRunResult(1, "", "nope"),
|
|
):
|
|
with self.assertRaises(EgressApplyError):
|
|
egress_apply.SmolmachinesEgressApplicator()._signal_bundle_reload("dev-abc")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|