Implement runit support for Fenris monitoring (issue #84)
Deliver end-to-end native monitoring path under runit with existing CLI/TUI controls and truthful status, preserving systemd behavior. Changes: - Add init system abstraction layer (src/fenris/init_system.py) that detects systemd vs runit and provides unified interface for timer control, on-demand collection, and service state queries - Create runit service files (units/runit/) with completion-relative 5-minute cadence, 2-minute boot delay, bounded execution (90s), no catch-up, and serialized runs via flock - Update monitor.py to use abstraction layer instead of direct systemctl - Update status.py to use abstraction layer for service state queries - Update all packaging scripts (deb, rpm) for init-system-aware setup - Update Makefile to install runit service files alongside systemd units - Add 46 tests for init system abstraction layer Spec: ADR 0008, §8.4, §8.5, §8.6, §8.7, §8.8 Closes #84 Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
co-authored by
CommandCodeBot
parent
37a0ed7030
commit
e27052d09a
+11
-26
@@ -56,8 +56,7 @@ class TestEnableIdempotentMatrix:
|
||||
"""A fresh package install has a store directory but no database yet."""
|
||||
args = MagicMock(now=False, store_path=store_path)
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(returncode=0)
|
||||
with patch("fenris.monitor.enable_timer") as mock_enable:
|
||||
cmd_enable(args)
|
||||
|
||||
conn = init_store(store_path)
|
||||
@@ -74,8 +73,7 @@ class TestEnableIdempotentMatrix:
|
||||
|
||||
args = MagicMock(now=False, store_path=store_path)
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(returncode=0)
|
||||
with patch("fenris.monitor.enable_timer") as mock_enable:
|
||||
cmd_enable(args)
|
||||
|
||||
# Period should be open
|
||||
@@ -100,8 +98,7 @@ class TestEnableIdempotentMatrix:
|
||||
|
||||
args = MagicMock(now=True, store_path=store_path)
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(returncode=0)
|
||||
with patch("fenris.monitor.enable_timer") as mock_enable:
|
||||
cmd_enable(args)
|
||||
|
||||
# Should still have exactly one open period
|
||||
@@ -125,8 +122,7 @@ class TestEnableIdempotentMatrix:
|
||||
|
||||
args = MagicMock(now=True, store_path=store_path)
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(returncode=0)
|
||||
with patch("fenris.monitor.enable_timer") as mock_enable:
|
||||
cmd_enable(args)
|
||||
|
||||
# Should have a new open period
|
||||
@@ -155,8 +151,7 @@ class TestDisableIdempotentMatrix:
|
||||
|
||||
args = MagicMock(now=True, store_path=store_path)
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(returncode=0)
|
||||
with patch("fenris.monitor.disable_timer") as mock_disable:
|
||||
cmd_disable(args)
|
||||
|
||||
# Period should be closed with user_disabled
|
||||
@@ -174,8 +169,7 @@ class TestDisableIdempotentMatrix:
|
||||
|
||||
args = MagicMock(now=True, store_path=store_path)
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(returncode=0)
|
||||
with patch("fenris.monitor.disable_timer") as mock_disable:
|
||||
cmd_disable(args)
|
||||
|
||||
# No periods should exist
|
||||
@@ -207,28 +201,19 @@ class TestDisableIdempotentMatrix:
|
||||
class TestCollectTrigger:
|
||||
"""§8.7: On-demand collection via helper path."""
|
||||
|
||||
def test_collect_triggers_systemctl_start(self):
|
||||
"""Collect starts fenris-collect.service synchronously."""
|
||||
def test_collect_triggers_init_system(self):
|
||||
"""Collect triggers init_system.collect_now."""
|
||||
args = MagicMock()
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(returncode=0)
|
||||
with patch("fenris.monitor.collect_now") as mock_collect:
|
||||
cmd_collect(args)
|
||||
|
||||
mock_sub.run.assert_called_once_with(
|
||||
["systemctl", "start", "fenris-collect.service"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
mock_collect.assert_called_once()
|
||||
|
||||
def test_collect_failure_exits_nonzero(self):
|
||||
"""Collect failure exits with nonzero status."""
|
||||
args = MagicMock()
|
||||
|
||||
with patch("fenris.monitor.subprocess") as mock_sub:
|
||||
mock_sub.run.return_value = MagicMock(
|
||||
returncode=1, stderr="Unit not found"
|
||||
)
|
||||
with patch("fenris.monitor.collect_now", side_effect=SystemExit(1)):
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
cmd_collect(args)
|
||||
assert exc_info.value.code == 1
|
||||
|
||||
Reference in New Issue
Block a user