38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class LiveEdgeWatchdogTests(unittest.TestCase):
|
|
def test_install_stack_registers_edge_watchdog(self) -> None:
|
|
common = (ROOT / "scripts" / "linux" / "lib" / "common.sh").read_text(encoding="utf-8")
|
|
self.assertIn("live-edge-watch.service", common)
|
|
self.assertIn("ExecStart=/bin/bash $ROOT_DIR/scripts/linux/live_edge_watch.sh", common)
|
|
self.assertIn("Restart=always", common)
|
|
self.assertIn("systemctl enable --now live-edge-watch.service", common)
|
|
|
|
def test_watchdog_repairs_inactive_or_unhealthy_edge(self) -> None:
|
|
watch = (ROOT / "scripts" / "linux" / "live_edge_watch.sh").read_text(encoding="utf-8")
|
|
self.assertIn("LIVE_EDGE_WATCH_INTERVAL", watch)
|
|
self.assertIn("systemctl start live-console.service", watch)
|
|
self.assertIn("systemctl start live-edge.service", watch)
|
|
self.assertIn("http://127.0.0.1/health", watch)
|
|
self.assertIn("systemctl restart live-edge.service", watch)
|
|
|
|
def test_uninstall_removes_edge_watchdog(self) -> None:
|
|
uninstall = (ROOT / "scripts" / "linux" / "uninstall_stack.sh").read_text(encoding="utf-8")
|
|
self.assertIn("live-edge-watch.service live-edge.service", uninstall)
|
|
self.assertIn("rm -f /etc/systemd/system/live-edge-watch.service", uninstall)
|
|
|
|
def test_stack_env_exposes_watch_interval(self) -> None:
|
|
env_example = (ROOT / "config" / "system-stack.env.example").read_text(encoding="utf-8")
|
|
self.assertIn("LIVE_EDGE_WATCH_INTERVAL=15", env_example)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|