Add module probes and worker telemetry

This commit is contained in:
2026-07-31 22:48:07 +02:00
parent b84cab1aa4
commit 05ce4dc8ec
7 changed files with 422 additions and 14 deletions
+65
View File
@@ -0,0 +1,65 @@
from __future__ import annotations
from dataclasses import dataclass
from govoplan_core.core.operations import (
OperationalCheck,
OperationalCheckProviderRegistration,
)
from govoplan_ops.backend.api.v1 import routes
@dataclass
class _Manifest:
operational_check_providers: tuple[OperationalCheckProviderRegistration, ...]
class _Registry:
def __init__(self, *registrations: OperationalCheckProviderRegistration):
self._manifest = _Manifest(tuple(registrations))
def manifests(self):
return (self._manifest,)
def test_module_operational_checks_cache_and_force() -> None:
routes._module_check_cache.clear()
calls = 0
def provider() -> OperationalCheck:
nonlocal calls
calls += 1
return OperationalCheck("example.roundtrip", "Example", "ok", "Passed")
registration = OperationalCheckProviderRegistration(
module_id="example",
check_id="example.roundtrip",
provider=provider,
)
registry = _Registry(registration)
assert routes._module_operational_checks(registry, force=False)[0]["state"] == "ok"
assert routes._module_operational_checks(registry, force=False)[0]["state"] == "ok"
assert calls == 1
routes._module_operational_checks(registry, force=True)
assert calls == 2
def test_module_operational_check_failure_is_isolated() -> None:
routes._module_check_cache.clear()
def provider() -> OperationalCheck:
raise RuntimeError("secret detail")
result = routes._module_operational_checks(
_Registry(OperationalCheckProviderRegistration(
module_id="example",
check_id="example.failed",
provider=provider,
)),
force=True,
)[0]
assert result["state"] == "error"
assert "secret detail" not in result["detail"]