feat: ingest burst hardening — defer lifecycle/auth, workers, nginx (v0.5.5)
Defer notify_lifecycle and notify_auth_login after commit; SAC_UVICORN_WORKERS via sac-api-start.sh; nginx /api/v1/events timeout; mass-update confirm in Hosts UI.
This commit is contained in:
@@ -133,3 +133,48 @@ def test_ingest_daily_report_calls_notify_daily_report(client, auth_headers):
|
||||
mock_daily.assert_called_once()
|
||||
mock_event.assert_not_called()
|
||||
|
||||
|
||||
def test_ingest_lifecycle_defers_notify(client, auth_headers):
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.api.v1 import events as events_api
|
||||
|
||||
event_id = str(uuid.uuid4())
|
||||
payload = {
|
||||
**VALID_EVENT,
|
||||
"event_id": event_id,
|
||||
"type": "agent.lifecycle",
|
||||
"title": "started",
|
||||
"summary": "agent started",
|
||||
"details": {"lifecycle": "started"},
|
||||
}
|
||||
with patch.object(events_api, "schedule_notify_lifecycle") as mock_defer:
|
||||
with patch.object(events_api, "notify_lifecycle") as mock_sync:
|
||||
r = client.post("/api/v1/events", json=payload, headers=auth_headers)
|
||||
assert r.status_code == 201
|
||||
mock_defer.assert_called_once()
|
||||
mock_sync.assert_not_called()
|
||||
|
||||
|
||||
def test_ingest_auth_login_defers_notify(client, auth_headers):
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.api.v1 import events as events_api
|
||||
|
||||
event_id = str(uuid.uuid4())
|
||||
payload = {
|
||||
**VALID_EVENT,
|
||||
"event_id": event_id,
|
||||
"category": "auth",
|
||||
"type": "ssh.login.success",
|
||||
"severity": "info",
|
||||
"title": "SSH login",
|
||||
"summary": "user@host",
|
||||
}
|
||||
with patch.object(events_api, "schedule_notify_auth_login") as mock_defer:
|
||||
with patch.object(events_api, "notify_auth_login") as mock_sync:
|
||||
r = client.post("/api/v1/events", json=payload, headers=auth_headers)
|
||||
assert r.status_code == 201
|
||||
mock_defer.assert_called_once()
|
||||
mock_sync.assert_not_called()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user