#5210 "Problems first, with since-time, across every list" (milestone 477), first batch. - Alerts: the Active list reads firing, no data, acknowledged, pending, the longest-running first, and re-polls itself. An acknowledged alert says how long it has been breaching (from the alert's events; acknowledging moves last_transition_at) and, apart from that, who acknowledged it and when. Rules show what each is doing now; disabled rules sort last. The current value reads the latest-value table (#5208) instead of plugin_metrics. - Monitors: a down monitor says "Down 12m · connection refused" in the list. - Hosts: sorted down, agent gone quiet, pending, healthy. The agent column shows "—" for a missing reading (was 0%) and a Stale badge with its age. agent_metrics_by_host is gone; the list reads agent_overview_by_host. - Schedules: failing first (failed or interrupted run, or a firing that could not start one), then running, then the rest, paused last; status badge from the shared states. - Maintenance windows: active (ending soonest), then upcoming (starting soonest), with expired folded away; each says when it ends/starts/ended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.6 KiB
Python
32 lines
1.6 KiB
Python
"""Lists put what needs looking at first (#5210): hosts by their worst
|
|
signal, schedules failing first, maintenance windows active then upcoming."""
|
|
from types import SimpleNamespace as NS
|
|
|
|
from steward.ansible.routes import _schedule_order
|
|
from steward.hosts.service import host_rank
|
|
|
|
|
|
def test_hosts_sort_down_then_quiet_agent_then_pending_then_healthy():
|
|
down, up, pending = {"state": "down"}, {"state": "up"}, {"state": "pending"}
|
|
fresh, quiet = {"fresh": True}, {"fresh": False}
|
|
assert host_rank(down, fresh) == 0
|
|
assert host_rank(up, quiet) == 1 # monitors fine, but the agent went silent
|
|
assert host_rank(None, quiet) == 1
|
|
assert host_rank(pending, fresh) == 2
|
|
assert host_rank(up, fresh) == 3 and host_rank(None, fresh) == 3
|
|
assert host_rank(None, None) == 4 # nothing watches it
|
|
|
|
|
|
def _sched(name, *, enabled=True, last_error=None, status=None):
|
|
run = NS(status=NS(value=status)) if status else None
|
|
return {"s": NS(name=name, enabled=enabled, last_error=last_error), "last_run": run}
|
|
|
|
|
|
def test_schedules_sort_failing_first_and_paused_last():
|
|
rows = [_sched("nightly", status="success"), _sched("paused", enabled=False, status="failed"),
|
|
_sched("backup", status="failed"), _sched("deploy", status="running"),
|
|
_sched("broken", last_error="source not found"), _sched("cut", status="interrupted"),
|
|
_sched("busy", last_error="the last run is still going", status="success")]
|
|
assert [r["s"].name for r in sorted(rows, key=_schedule_order)] == [
|
|
"backup", "broken", "cut", "deploy", "busy", "nightly", "paused"]
|