You've already forked directdnsonly
feat: operational status endpoint + reconciler/peer state tracking 📊
- ReconciliationWorker._last_run stores per-pass stats (da_servers_polled, zones_in_da/db, orphans_found/queued, hostnames_backfilled/migrated, zones_healed, duration_seconds, dry_run flag) - ReconciliationWorker.get_status() exposes state for API/UI consumption - _heal_backends() now returns healed count - PeerSyncWorker.get_peer_status() serialises _peer_health to JSON-safe dict (url, healthy, consecutive_failures, last_seen) with summary totals - WorkerManager tracks dead-letter count; queue_status() now returns nested reconciler/peer_sync dicts replacing flat reconciler_alive/peer_syncer_alive - New GET /status endpoint (StatusAPI) aggregates queue depths, worker liveness, reconciler last-run, peer health, and live zone count; computes ok/degraded/error - .gitignore: exclude .claude/, .vscode/, .env (always local) - app.yml: add documented datastore section (SQLite default + MySQL commented) - 164 tests passing (23 new tests added)
This commit is contained in:
@@ -394,3 +394,53 @@ def test_sync_empty_peer_list(patch_connect, monkeypatch):
|
||||
monkeypatch.setattr("directdnsonly.app.peer_sync.requests.get", mock_get)
|
||||
|
||||
worker._sync_from_peer(_make_peer())
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# get_peer_status
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_get_peer_status_no_contact_yet():
|
||||
worker = PeerSyncWorker(BASE_CONFIG)
|
||||
status = worker.get_peer_status()
|
||||
|
||||
assert status["enabled"] is True
|
||||
assert status["total"] == 1
|
||||
assert status["healthy"] == 1
|
||||
assert status["degraded"] == 0
|
||||
assert status["peers"][0]["url"] == "http://ddo-2:2222"
|
||||
assert status["peers"][0]["healthy"] is True
|
||||
assert status["peers"][0]["last_seen"] is None
|
||||
|
||||
|
||||
def test_get_peer_status_after_success():
|
||||
worker = PeerSyncWorker(BASE_CONFIG)
|
||||
worker._record_success("http://ddo-2:2222")
|
||||
status = worker.get_peer_status()
|
||||
|
||||
assert status["healthy"] == 1
|
||||
assert status["degraded"] == 0
|
||||
assert status["peers"][0]["last_seen"] is not None
|
||||
|
||||
|
||||
def test_get_peer_status_after_degraded():
|
||||
from directdnsonly.app.peer_sync import FAILURE_THRESHOLD
|
||||
|
||||
worker = PeerSyncWorker(BASE_CONFIG)
|
||||
for _ in range(FAILURE_THRESHOLD):
|
||||
worker._record_failure("http://ddo-2:2222", Exception("timeout"))
|
||||
|
||||
status = worker.get_peer_status()
|
||||
assert status["healthy"] == 0
|
||||
assert status["degraded"] == 1
|
||||
assert status["peers"][0]["healthy"] is False
|
||||
|
||||
|
||||
def test_get_peer_status_disabled():
|
||||
worker = PeerSyncWorker({})
|
||||
status = worker.get_peer_status()
|
||||
|
||||
assert status["enabled"] is False
|
||||
assert status["total"] == 0
|
||||
assert status["peers"] == []
|
||||
|
||||
Reference in New Issue
Block a user