Docker panel (#5276): problems first, then the 8 busiest running containers by CPU; the other running and the stopped fold behind one "+N more running · M stopped" line. Containers that are not swarm tasks read the way the Docker page reads them: CI jobs as "CI: workflow · job", buildx builders as "BuildKit builder · name". Monitors card (#5277): the edit/delete icon buttons and the inline add form are gone. Each row links to its monitor's page; "Add monitor" opens the add form filed under this host, starting from its address, with the host in its breadcrumbs and Cancel back to it. Agent card (#5278): Full metrics stays in view; Update, Rotate token, Unregister agent (was "Remove") and Re-provision sit under "Manage agent". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.9 KiB
Python
55 lines
2.9 KiB
Python
"""The host page: what sits where (#5214)."""
|
|
from types import SimpleNamespace
|
|
|
|
from quart import render_template, session
|
|
|
|
|
|
async def test_ansible_comes_before_the_docker_list(app, monkeypatch):
|
|
# The Docker list can run to dozens of containers; Ansible under it was
|
|
# easy to miss, so it sits above.
|
|
monkeypatch.setitem(app.config, "PLUGINS", {"docker": {"enabled": True}})
|
|
host = SimpleNamespace(id="h1", name="box", address="10.0.0.5")
|
|
async with app.test_request_context("/hosts/h1"):
|
|
session["user_role"] = "operator"
|
|
page = await render_template(
|
|
"hosts/detail.html", host=host, monitors=[], uptime=None, alerts=[],
|
|
linked_target=None, linkable_targets=[], ansible_sources=[])
|
|
docker = page.index('hx-get="/plugins/docker/host/h1"')
|
|
assert page.index(">Ansible</h3>") < docker
|
|
assert page.index('hx-get="/plugins/host_agent/panel/h1"') < docker
|
|
# Monitors are added on their own form, filed under this host (#5277);
|
|
# each row's own page has the labelled Edit/Pause/Delete.
|
|
assert 'href="/monitors/new?host_id=h1"' in page
|
|
assert "row-actions" not in page and 'action="/monitors/add"' not in page
|
|
|
|
|
|
async def test_adding_a_monitor_from_a_host_page_says_whose_it_is(app):
|
|
host = SimpleNamespace(id="h1", name="box", address="10.0.0.5")
|
|
async with app.test_request_context("/monitors/new?host_id=h1"):
|
|
session["user_role"] = "operator"
|
|
page = await render_template(
|
|
"monitors/form.html", monitor=None, host=host, mtype="icmp", config={}, types=[],
|
|
values={"name": "", "target": "10.0.0.5", "host_id": "h1", "check_interval_seconds": 0})
|
|
assert '<a href="/hosts/h1">box</a>' in page # crumb and hint name the host
|
|
assert 'name="host_id" value="h1"' in page and 'value="10.0.0.5"' in page
|
|
assert 'href="/hosts/h1" class="btn btn-sm btn-ghost">Cancel' in page
|
|
|
|
|
|
async def test_the_agent_card_keeps_its_actions_under_manage(app):
|
|
"""#5278: "Remove" said nothing about what it removed."""
|
|
from datetime import datetime, timezone
|
|
from tests._templates import render_plugin_template
|
|
host = SimpleNamespace(id="h1", name="box", address="10.0.0.5")
|
|
reg = SimpleNamespace(agent_version="1.8.0", last_seen_at=datetime.now(timezone.utc))
|
|
target = SimpleNamespace(id="t1", name="box")
|
|
async with app.test_request_context("/plugins/host_agent/panel/h1"):
|
|
session["user_role"] = "admin"
|
|
page = await render_plugin_template(
|
|
app, "host_agent", "panel.html", host=host, reg=reg, reporting=True, stale=False,
|
|
target=target, ansible_available=True, managed_key_set=True)
|
|
manage = page.index(">Manage agent</summary>")
|
|
assert page.index("Full metrics →") < manage
|
|
for action in (">Update agent</button>", ">Rotate token</button>", ">Unregister agent</button>"):
|
|
assert page.index(action) > manage
|
|
assert ">Remove</button>" not in page
|