M14: add n8n execution health telemetry
This commit is contained in:
@@ -264,3 +264,40 @@ def test_procedures_sync_result_registers_and_is_idempotent(client, ops_client):
|
||||
status = ops_client.get("/api/v1/integrations/status").json()["n8n"]
|
||||
ragcore_sync = next(w for w in status["workflows"] if "RAGcore" in w["name"])
|
||||
assert ragcore_sync["last_seen_at"] is not None
|
||||
|
||||
|
||||
def test_workflow_heartbeat_is_idempotent_and_drives_live_status(client, ops_client):
|
||||
settings = get_settings()
|
||||
execution_id = str(uuid.uuid4())
|
||||
body = {
|
||||
"workflow_id": "mobilityops-scheduled-quality-scan",
|
||||
"workflow_name": "Fleet Ops — Scheduled Data Quality Scan",
|
||||
"execution_id": execution_id,
|
||||
"status": "succeeded",
|
||||
}
|
||||
headers = {"X-Service-Token": settings.n8n_callback_token}
|
||||
first = client.post("/api/v1/integrations/n8n/heartbeat", json=body, headers=headers)
|
||||
second = client.post("/api/v1/integrations/n8n/heartbeat", json=body, headers=headers)
|
||||
assert first.status_code == 200
|
||||
assert first.json()["status"] == "registered"
|
||||
assert second.json()["status"] == "already_registered"
|
||||
|
||||
status = ops_client.get("/api/v1/integrations/status").json()["n8n"]
|
||||
workflow = next(w for w in status["workflows"] if w["name"] == body["workflow_name"])
|
||||
assert workflow["state"] == "healthy"
|
||||
assert workflow["last_status"] == "succeeded"
|
||||
assert workflow["last_execution_id"] == execution_id
|
||||
|
||||
|
||||
def test_workflow_heartbeat_rejects_unknown_workflow(client):
|
||||
response = client.post(
|
||||
"/api/v1/integrations/n8n/heartbeat",
|
||||
json={
|
||||
"workflow_id": "unknown",
|
||||
"workflow_name": "Unknown workflow",
|
||||
"execution_id": "test-unknown-001",
|
||||
"status": "succeeded",
|
||||
},
|
||||
headers={"X-Service-Token": get_settings().n8n_callback_token},
|
||||
)
|
||||
assert response.status_code == 422
|
||||
|
||||
Reference in New Issue
Block a user