#5290 "Host page: the health tiles span the card's width; even spacing above Ansible": the four tiles take equal quarters (halves on a phone) and their sparklines stretch across them; the Monitors + Agent row drops the Agent card's own margin, so the gap above Ansible is 1rem like every other. #5291 "Add host opens as a dialog over the Hosts list": a native <dialog> on /hosts/, opened by Add host or /hosts/?add=1. A name clash re-renders the list with it open, the error and what was typed. GET /hosts/new is gone; hosts/form.html is Edit only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
2.0 KiB
Python
41 lines
2.0 KiB
Python
"""The agent fleet page opens on the fleet itself: a status column, silent
|
|
agents first (#5126)."""
|
|
from datetime import datetime, timedelta, timezone
|
|
from types import SimpleNamespace as NS
|
|
|
|
from plugins.host_agent.routes import fleet_rows, fleet_state
|
|
from tests._templates import render_plugin_template
|
|
|
|
|
|
def _reg(host_id, seen_ago_s):
|
|
now = datetime.now(timezone.utc)
|
|
return NS(host_id=host_id, last_seen_at=None if seen_ago_s is None else now - timedelta(seconds=seen_ago_s),
|
|
host_ip="10.0.0.5", agent_version="1.4.0", distro="debian")
|
|
|
|
|
|
def test_fleet_state():
|
|
now = datetime.now(timezone.utc)
|
|
assert fleet_state(_reg("a", 30), now, 180) == "up"
|
|
assert fleet_state(_reg("a", 600), now, 180) == "stale"
|
|
assert fleet_state(_reg("a", None), now, 180) == "pending"
|
|
|
|
|
|
async def test_silent_agents_come_first_and_the_table_leads_the_page(app):
|
|
now = datetime.now(timezone.utc)
|
|
hosts = {i: NS(id=i, name=n) for i, n in [("h1", "web"), ("h2", "nas"), ("h3", "attic")]}
|
|
rows = fleet_rows([_reg("h1", 30), _reg("h2", 900), _reg("h3", None)], hosts, now, 180)
|
|
assert [r["name"] for r in rows] == ["nas", "attic", "web"]
|
|
|
|
async with app.test_request_context("/plugins/host_agent/fleet/"):
|
|
page = await render_plugin_template(app, "host_agent", "settings_list.html", registrations=rows,
|
|
new_token=None, install_url=None, ansible_available=False,
|
|
deploy_targets=[], deploy_groups=[], managed_key_set=False)
|
|
|
|
# Hosts are added in one place, the Add host dialog on Hosts (#5282, #5291).
|
|
assert "fleet/add-host" not in page and 'href="/hosts/?add=1"' in page
|
|
assert '<span class="badge badge-warn">Silent</span>' in page
|
|
assert '<span class="badge badge-warn">Never reported</span>' in page
|
|
assert '<span class="badge badge-ok">Reporting</span>' in page
|
|
assert page.index('href="/hosts/h2">nas</a>') < page.index('href="/hosts/h1">web</a>')
|
|
assert 'data-confirm="Unregister the agent for nas?' in page
|