ServiceMap: update tests and backend/app (+7 areas)

Public changes compared with the previous published export:
89 files changed.

Affected areas:
- backend/app: 21 files
- dependencies: 5 files
- deployment and CI: 6 files
- documentation: 2 files
- frontend: 3 files
- frontend/src: 20 files
- project files: 1 file
- tests: 30 files
- unraid: 1 file

Changed files:
- Updated: ".env.example"
- Updated: "Dockerfile.unraid"
- Updated: "README.md"
- Updated: "backend/Dockerfile"
- Added: "backend/app/alerts.py"
- Updated: "backend/app/auth.py"
- Added: "backend/app/backups.py"
- Updated: "backend/app/config_io.py"
- Updated: "backend/app/demo.py"
- Updated: "backend/app/discovery.py"
- Updated: "backend/app/discovery_store.py"
- Updated: "backend/app/docker_discovery.py"
- Updated: "backend/app/events.py"
- Updated: "backend/app/evidence.py"
- Updated: "backend/app/health.py"
- Updated: "backend/app/incidents.py"
- Added: "backend/app/loops.py"
- Updated: "backend/app/main.py"
- Updated: "backend/app/models.py"
- Updated: "backend/app/observation.py"
- Updated: "backend/app/probes.py"
- Added: "backend/app/response_cache.py"
- Updated: "backend/app/scheduler.py"
- Updated: "backend/app/semantic.py"
- Updated: "backend/app/store.py"
- Updated: "backend/pyproject.toml"
- Updated: "backend/tests/test_api.py"
- Updated: "backend/tests/test_config_io.py"
- Updated: "backend/tests/test_demo.py"
- Updated: "backend/tests/test_discovery_v120.py"
- Updated: "backend/tests/test_health.py"
- Updated: "backend/tests/test_probes.py"
- Updated: "backend/tests/test_scheduler.py"
- Updated: "backend/tests/test_v130_probe_reachability.py"
- Updated: "backend/tests/test_v160_evidence_changes.py"
- Added: "backend/tests/test_v163_alerts.py"
- Added: "backend/tests/test_v163_backups.py"
- Added: "backend/tests/test_v163_data_integrity.py"
- Added: "backend/tests/test_v163_efficiency.py"
- Added: "backend/tests/test_v163_health_performance.py"
- Added: "backend/tests/test_v163_loops.py"
- Added: "backend/tests/test_v163_management.py"
- Added: "backend/tests/test_v163_realtime.py"
- Added: "backend/tests/test_v163_security.py"
- Added: "backend/tests/test_v163_semantic_etag.py"
- Added: "compose.demo.yaml"
- Updated: "compose.yaml"
- Added: "docker-compose.broker.yml"
- Updated: "docker-compose.yml"
- Updated: "docs/ARCHITECTURE.md"
- Added: "frontend/e2e/a11y.spec.ts"
- Updated: "frontend/e2e/demo.spec.ts"
- Updated: "frontend/index.html"
- Updated: "frontend/nginx.conf"
- Updated: "frontend/package-lock.json"
- Updated: "frontend/package.json"
- Updated: "frontend/playwright.config.ts"
- Updated: "frontend/src/App.tsx"
- Updated: "frontend/src/LivingEdge.tsx"
- Added: "frontend/src/activityView.test.ts"
- Added: "frontend/src/activityView.ts"
- Updated: "frontend/src/api.ts"
- Added: "frontend/src/apiAuth.test.ts"
- Added: "frontend/src/components/ActionsMenu.tsx"
- Added: "frontend/src/components/ConfirmDialog.test.tsx"
- Added: "frontend/src/components/ConfirmDialog.tsx"
- Added: "frontend/src/components/StatusIcon.tsx"
- Updated: "frontend/src/demo/DemoWalkthrough.test.ts"
- Updated: "frontend/src/demo/DemoWalkthrough.tsx"
- Added: "frontend/src/elk-worker-url.d.ts"
- Added: "frontend/src/labels.ts"
- Updated: "frontend/src/main.tsx"
- Added: "frontend/src/realtime/refreshPlan.test.ts"
- Added: "frontend/src/realtime/refreshPlan.ts"
- Updated: "frontend/src/realtime/useRealtimeEvents.ts"
- Added: "frontend/src/routing/urlState.test.ts"
- Added: "frontend/src/routing/urlState.ts"
- Updated: "frontend/src/styles.css"
- Added: "frontend/src/topology/GraphListView.test.tsx"
- Added: "frontend/src/topology/GraphListView.tsx"
- Updated: "frontend/src/topology/ServiceNode.tsx"
- Updated: "frontend/src/topology/TopologyCommandBar.tsx"
- Added: "frontend/src/topology/semanticGraph.test.ts"
- Updated: "frontend/src/topology/semanticGraph.ts"
- Added: "frontend/src/topologyLayout.test.ts"
- Updated: "frontend/src/topologyLayout.ts"
- Updated: "package-lock.json"
- Updated: "package.json"
- Updated: "unraid/my-servicemap.xml"

Export provenance/manifests refreshed; excluded from the change summary.

Publish curated ServiceMap source from af46f684e468dffd3a5190e28d3b572d4c26bfd7
This commit is contained in:
NuklearRabbit committed 2026-11-20 13:51:46 +01:00
1 parent d7319250e8
commit adc2c70c21
91 files changed
+9205 -1691

No files matched your search

+131
View File
@@ -0,0 +1,131 @@
"""v1.6.3 operator management: maintenance windows, incident lifecycle, events."""
from __future__ import annotations
from datetime import UTC, datetime, timedelta
from pathlib import Path
import pytest
from fastapi.testclient import TestClient
from app import main as main_module
from app.discovery import DiscoveryManager
from app.discovery_store import DiscoveryStore
from app.models import IncidentRecord, IncidentStatus, ServiceCreate, ServiceKind
from app.store import Store
@pytest.fixture()
def store(tmp_path: Path) -> Store:
return Store(str(tmp_path / "servicemap.db"))
def _service(store: Store, name: str = "API"):
return store.create_service(ServiceCreate(name=name, kind=ServiceKind.HTTP, url=f"https://{name.lower()}.test"))
def _incident(store: Store, root_id: str) -> IncidentRecord:
now = datetime.now(UTC)
record = IncidentRecord(
id="inc-1",
status=IncidentStatus.OPEN,
root_service_id=root_id,
root_service_name="API",
started_at=now,
detected_at=now,
title="API is down",
root_cause_reason="test",
latest_update_at=now,
)
store.upsert_incident(record)
return record
def test_maintenance_window_ends_automatically(store: Store) -> None:
service = _service(store)
until = datetime.now(UTC) + timedelta(minutes=30)
store.set_maintenance(service.id, True, "Patching", until)
assert store.maintenance_windows()[service.id] == until
assert store.get_service(service.id).maintenance_enabled
# Not yet due.
assert store.expire_maintenance_windows(datetime.now(UTC)) == []
# Due: maintenance ends and the window disappears.
assert store.expire_maintenance_windows(until + timedelta(seconds=1)) == [service.id]
assert not store.get_service(service.id).maintenance_enabled
assert store.maintenance_windows() == {}
# Ending maintenance by hand also removes a pending window.
store.set_maintenance(service.id, True, None, datetime.now(UTC) + timedelta(hours=1))
store.set_maintenance(service.id, False)
assert store.maintenance_windows() == {}
with pytest.raises(ValueError, match="toekomst"):
store.set_maintenance(service.id, True, None, datetime.now(UTC) - timedelta(minutes=1))
def test_incident_acknowledge_is_idempotent_and_can_be_resolved_with_notes(store: Store) -> None:
service = _service(store)
_incident(store, service.id)
first = store.acknowledge_incident("inc-1")
second = store.acknowledge_incident("inc-1")
assert second.acknowledged_at == first.acknowledged_at
timeline = [item.event_type for item in store.incident_timeline("inc-1")]
assert timeline.count("incident.acknowledged") == 1
store.add_incident_note("inc-1", "Restarted the container")
resolved = store.resolve_incident("inc-1", "false alarm")
assert resolved.status == IncidentStatus.RESOLVED and resolved.resolved_at is not None
messages = [item.message for item in store.incident_timeline("inc-1")]
assert "Restarted the container" in messages
assert any("handmatig opgelost: false alarm" in message for message in messages)
# Resolving again changes nothing.
assert store.resolve_incident("inc-1").resolved_at == resolved.resolved_at
def test_event_journal_filters_by_family_and_pages(store: Store) -> None:
service = _service(store)
_incident(store, service.id)
store.add_incident_note("inc-1", "one")
store.add_incident_note("inc-1", "two")
store.set_maintenance(service.id, True)
family = store.list_events(event_type="incident.")
assert family and all(item.event_type.startswith("incident.") for item in family)
exact = store.list_events(event_type="service.maintenance_changed")
assert [item.event_type for item in exact] == ["service.maintenance_changed"]
page = store.list_events(limit=2)
older = store.list_events(limit=50, before=page[-1].created_at)
assert all(item.created_at < page[-1].created_at for item in older)
assert {item.id for item in page}.isdisjoint({item.id for item in older})
def test_management_routes(tmp_path: Path) -> None:
main_module.store = Store(str(tmp_path / "servicemap.db"))
main_module.discovery_store = DiscoveryStore(main_module.store)
main_module.discovery_manager = DiscoveryManager(main_module.store, main_module.discovery_store)
client = TestClient(main_module.app)
service = _service(main_module.store)
_incident(main_module.store, service.id)
until = (datetime.now(UTC) + timedelta(hours=2)).isoformat()
response = client.post(f"/api/v1/services/{service.id}/maintenance", json={"enabled": True, "until": until})
assert response.status_code == 200
snapshot = client.get(f"/api/v1/services/{service.id}").json()
assert snapshot["maintenance_until"] is not None
past = (datetime.now(UTC) - timedelta(hours=1)).isoformat()
assert client.post(
f"/api/v1/services/{service.id}/maintenance", json={"enabled": True, "until": past}
).status_code == 422
note = client.post("/api/v1/incidents/inc-1/notes", json={"text": "Investigating"})
assert note.status_code == 200
assert any(item["message"] == "Investigating" for item in note.json()["timeline"])
resolved = client.post("/api/v1/incidents/inc-1/resolve", json={"note": "stale"})
assert resolved.json()["incident"]["status"] == "resolved"
assert client.post("/api/v1/incidents/missing/resolve").status_code == 404
events = client.get("/api/v1/events", params={"event_type": "incident."}).json()
assert events and all(item["event_type"].startswith("incident.") for item in events)