Phase 1 abgeschlossen: Node-Identitaet in Control Core verkabelt (§3.6, §6.3)
- NodeIdentity/NodeRole in hms_domain: persistente node_id aus userdata/identity, Rollen RENDER_NODE/COORDINATOR/CONTROL_DESK, plausible Kombinationen validiert, keine Auto-Leader-Wahl (§6.3) - Control Core: create_app(identity) injizierbar; Dev-Modus ephemeral; Registry registriert eigene Node; neue Endpunkte /system/identity (ohne Secrets, §27.1) und /cluster/nodes (UI-Kategorien §6.3) - 16 neue/aktualisierte Integrationstests; Gesamtsuite 199 gruen
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
"""Integrationstests Control Core (PLAN.md §6.1B, §23, §36 Nr. 9).
|
||||
|
||||
FastAPI-REST + WebSocket mit derselben Parameter-Engine, die auch
|
||||
Art-Net bedient (§11: eine autoritative Instanz).
|
||||
Art-Net bedient (§11: eine autoritative Instanz). Node-Identität und
|
||||
Cluster-Registry sind verkabelt (§6.3).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -11,6 +12,7 @@ import uuid
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from hms_control_server import create_app
|
||||
from hms_domain import NodeIdentity, NodeRole
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -18,6 +20,15 @@ def client() -> TestClient:
|
||||
return TestClient(create_app())
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def named_client() -> TestClient:
|
||||
"""App mit injizierter produktionsähnlicher Identität."""
|
||||
identity = NodeIdentity.ephemeral(
|
||||
"Show Server A", frozenset({NodeRole.RENDER_NODE, NodeRole.COORDINATOR})
|
||||
)
|
||||
return TestClient(create_app(identity=identity))
|
||||
|
||||
|
||||
def _payload(path: str, value: float) -> dict:
|
||||
return {"parameter_path": path, "value": value}
|
||||
|
||||
@@ -27,27 +38,63 @@ def path() -> str:
|
||||
return f"composition/{uuid.uuid4()}/layer/{uuid.uuid4()}/opacity"
|
||||
|
||||
|
||||
# ---------- Health/Capabilities ----------
|
||||
# ---------- Health/Capabilities/Identity ----------
|
||||
|
||||
|
||||
def test_health(client: TestClient) -> None:
|
||||
r = client.get("/api/v1/system/health")
|
||||
assert r.status_code == 200
|
||||
assert r.json()["status"] == "ok"
|
||||
assert r.json()["phase"] == 0
|
||||
assert r.json()["phase"] == 1
|
||||
assert r.json()["node_id"] # Identität in Health sichtbar
|
||||
|
||||
|
||||
def test_identity_reports_roles_without_secrets(named_client: TestClient) -> None:
|
||||
r = named_client.get("/api/v1/system/identity")
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert body["display_name"] == "Show Server A"
|
||||
assert body["roles"] == ["COORDINATOR", "RENDER_NODE"]
|
||||
assert body["renders_locally"] is True
|
||||
assert body["is_coordinator"] is True
|
||||
# keine vertraulichen Felder (§27.1)
|
||||
blob = str(body).lower()
|
||||
for forbidden in ("token", "secret", "password"):
|
||||
assert forbidden not in blob
|
||||
|
||||
|
||||
def test_two_apps_get_distinct_dev_identities() -> None:
|
||||
"""Ohne injizierte Identität erhält jede App-Instanz eine eigene ID
|
||||
(Dev-Modus; Showbetrieb nutzt persistente Identität über den Launcher)."""
|
||||
a = TestClient(create_app()).get("/api/v1/system/identity").json()
|
||||
b = TestClient(create_app()).get("/api/v1/system/identity").json()
|
||||
assert a["node_id"] != b["node_id"]
|
||||
|
||||
|
||||
def test_capabilities_reported_without_fake_tier(client: TestClient) -> None:
|
||||
r = client.get("/api/v1/system/capabilities")
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
assert body["tier"] is None # ungeprüft (CPU-only-Umgebung), kein Fake
|
||||
assert r.json()["tier"] is None # ungeprüft (CPU-only), kein Fake
|
||||
|
||||
|
||||
def test_diagnostics_reports_not_connected(client: TestClient) -> None:
|
||||
r = client.get("/api/v1/diagnostics")
|
||||
assert r.status_code == 200
|
||||
assert r.json()["renderer"] == "not_connected" # IPC-Handshake Phase 1
|
||||
assert r.json()["renderer"] == "not_connected"
|
||||
assert r.json()["node_id"]
|
||||
|
||||
|
||||
# ---------- Cluster-Registry (§6.3) ----------
|
||||
|
||||
|
||||
def test_self_node_listed_in_cluster_nodes(named_client: TestClient) -> None:
|
||||
r = named_client.get("/api/v1/cluster/nodes")
|
||||
assert r.status_code == 200
|
||||
body = r.json()
|
||||
self_entry = next(n for n in body["nodes"] if n["node_id"] == body["self"])
|
||||
assert self_entry["display_name"] == "Show Server A"
|
||||
assert set(self_entry["roles"]) == {"RENDER_NODE", "COORDINATOR"}
|
||||
assert self_entry["health"] in ("online", "offline") # ohne Heartbeat offline
|
||||
|
||||
|
||||
# ---------- Commands (§23.2) ----------
|
||||
@@ -66,7 +113,7 @@ def test_duplicate_command_id_is_idempotent(client: TestClient, path: str) -> No
|
||||
first = client.post("/api/v1/commands", json=cmd).json()
|
||||
second = client.post("/api/v1/commands", json=cmd).json()
|
||||
assert first["status"] == "ack"
|
||||
assert second.get("duplicate") is True # gleiches Ack, kein Doppel-Apply
|
||||
assert second.get("duplicate") is True
|
||||
assert second["result"]["revision"] == first["revision"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user