atlasbot/tests/test_snapshot.py

31 lines
1.1 KiB
Python
Raw Permalink Normal View History

2026-01-28 11:46:52 -03:00
from atlasbot.snapshot.builder import build_summary
def test_build_summary_basic() -> None:
snapshot = {
"nodes_summary": {"total": 2, "ready": 2, "not_ready": 0},
"nodes_detail": [
{"name": "titan-01", "hardware": "rpi5"},
{"name": "titan-02", "hardware": "amd64"},
],
"metrics": {
"pods_running": 10,
"pods_pending": 0,
"pods_failed": 0,
"pods_succeeded": 1,
"postgres_connections": {"used": 5, "max": 100, "hottest_db": {"label": "synapse", "value": 3}},
"node_usage": {
"cpu": [{"node": "titan-01", "value": 30}],
"ram": [{"node": "titan-02", "value": 70}],
"net": [{"node": "titan-02", "value": 1.2}],
"io": [{"node": "titan-01", "value": 0.5}],
},
},
}
summary = build_summary(snapshot)
assert summary["nodes"]["total"] == 2
assert "rpi5" in summary["hardware"]
assert summary["pods"]["running"] == 10
assert summary["postgres"]["hottest_db"]["label"] == "synapse"
assert summary["hottest"]["ram"]["node"] == "titan-02"