feat(widgets): Routers and Hosts problem rows say since when (#5810)
Routers: a router in trouble reads 'started 2h ago' or 'all of the last 24 h', from problem_since over the day's history, read for the troubled routers only (a certificate's problem carries its own date). Hosts: a down host reads 'a monitor is down for 3h'; host_glance keeps the down_since host_status already had. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,7 +120,8 @@ def test_hosts_sort_worst_first():
|
||||
th = to_thresholds_cfg({})
|
||||
hosts = [_host("a", "alpha"), _host("b", "busy"), _host("d", "dead"), _host("q", "quiet"),
|
||||
_host("w", "warm"), _host("n", "nothing")]
|
||||
status = {"d": {"state": "down"}, "a": {"state": "up"}}
|
||||
went = datetime(2026, 10, 15, 9, 0, tzinfo=timezone.utc)
|
||||
status = {"d": {"state": "down", "down_since": went}, "a": {"state": "up", "down_since": None}}
|
||||
agent = {"alpha": {"cpu_pct": 10.0, "fresh": True}, "busy": {"cpu_pct": 99.0, "fresh": True},
|
||||
"quiet": {"cpu_pct": 99.0, "fresh": False},
|
||||
"warm": {"cpu_pct": 10.0, "load_per_core": 85, "fresh": True}}
|
||||
@@ -130,6 +131,17 @@ def test_hosts_sort_worst_first():
|
||||
("alpha", "up"), ("nothing", "unknown")]
|
||||
assert rows[1]["worst"][0] == "CPU" and rows[3]["worst"][0] == "Load"
|
||||
assert rows[2]["worst"] is None # a quiet agent's old figures aren't graded
|
||||
assert rows[0]["down_since"] == went and rows[4]["down_since"] is None # #5810
|
||||
|
||||
|
||||
async def test_a_down_host_says_for_how_long(app):
|
||||
"""#5810: the problem row carries its since, as the Hosts list does."""
|
||||
rows = [{"host": _host("d", "dead"), "state": "down", "worst": None, "agent": {},
|
||||
"down_since": datetime.now(timezone.utc) - timedelta(hours=3)}]
|
||||
async with app.test_request_context("/hosts/overview/widget"):
|
||||
page = await render_template("hosts/overview_widget.html", rows=rows)
|
||||
page = " ".join(page.split())
|
||||
assert "a monitor is down for" in page and ">3h<" in page and " ago" not in page
|
||||
|
||||
|
||||
async def test_the_hosts_widget_gives_a_verdict_and_load_against_cores(app):
|
||||
|
||||
Reference in New Issue
Block a user