fix: pipeline reliability — WS, summarizer, ingest, health
Stop the live HUD reconnect storm (nginx WS snippet + backoff), copy intel/nous_client into the summarizer image, and make event ingest idempotent on URL. GDELT uses the DOC API; NWS no longer sends bbox; FIRMS is one ON CONFLICT batch; GET /api/aircraft serves last-known. Health reports freshness without 503ing docker. EONET + CISA KEV added.
This commit is contained in:
parent
c6bfc50705
commit
d81ea68dec
26 changed files with 1164 additions and 110 deletions
|
|
@ -472,3 +472,103 @@ def test_transform_ais_position_decodes_navstat():
|
|||
assert row is not None
|
||||
assert row["extra"]["nav"] == "moored"
|
||||
assert row["extra"]["navstat"] == 5
|
||||
|
||||
|
||||
def test_nws_alerts_does_not_send_bbox_param(monkeypatch):
|
||||
"""api.weather.gov/alerts/active 400s on bbox — clip locally instead."""
|
||||
import asyncio
|
||||
|
||||
from live_layers import fetch_weather_alerts, _cache
|
||||
|
||||
seen = []
|
||||
|
||||
async def fake_get(url, params=None):
|
||||
seen.append((url, dict(params or {})))
|
||||
if "weather.gov" in url:
|
||||
return {
|
||||
"type": "FeatureCollection",
|
||||
"features": [{
|
||||
"type": "Feature",
|
||||
"properties": {"event": "Tornado Warning", "severity": "Extreme"},
|
||||
"geometry": {"type": "Point", "coordinates": [-78.7, 35.8]},
|
||||
}],
|
||||
}
|
||||
return {"type": "FeatureCollection", "features": []}
|
||||
|
||||
monkeypatch.setattr("live_layers._get_json", fake_get)
|
||||
_cache.clear()
|
||||
fc = asyncio.run(fetch_weather_alerts(None, "-79.0,35.5,-78.0,36.0"))
|
||||
nws_calls = [p for u, p in seen if "weather.gov" in u]
|
||||
assert nws_calls, "NWS should still be fetched"
|
||||
assert "bbox" not in nws_calls[0]
|
||||
assert fc.get("nws_ok") is True
|
||||
assert len(fc["features"]) == 1
|
||||
|
||||
|
||||
def test_nws_alerts_failure_is_flagged(monkeypatch):
|
||||
import asyncio
|
||||
|
||||
from live_layers import fetch_weather_alerts, _cache
|
||||
|
||||
async def fake_get(url, params=None):
|
||||
if "weather.gov" in url:
|
||||
raise RuntimeError("400 Bad Request")
|
||||
return {"type": "FeatureCollection", "features": []}
|
||||
|
||||
monkeypatch.setattr("live_layers._get_json", fake_get)
|
||||
_cache.clear()
|
||||
fc = asyncio.run(fetch_weather_alerts(None, None))
|
||||
assert fc.get("nws_ok") is False
|
||||
|
||||
|
||||
def test_fetch_aircraft_get_path_does_not_persist(monkeypatch):
|
||||
"""GET /api/aircraft must serve last-known without track/geofence writes."""
|
||||
import asyncio
|
||||
|
||||
from live_layers import (
|
||||
aircraft_last_known, fetch_aircraft, persist_aircraft_snapshot, _cache,
|
||||
)
|
||||
|
||||
aircraft_last_known.clear()
|
||||
aircraft_last_known["abc"] = {
|
||||
"id": "abc", "lat": 35.8, "lon": -78.7, "heading": 90, "speed": 400,
|
||||
"label": "ABC", "extra": {},
|
||||
}
|
||||
writes = {"n": 0}
|
||||
|
||||
async def boom(*a, **k):
|
||||
writes["n"] += 1
|
||||
raise AssertionError("GET path must not persist")
|
||||
|
||||
monkeypatch.setattr("tracks.record_position", boom)
|
||||
monkeypatch.setattr("geofence.record_and_notify", boom)
|
||||
_cache.clear()
|
||||
rows = asyncio.run(fetch_aircraft("-79,35,-78,36", persist=False))
|
||||
assert writes["n"] == 0
|
||||
assert any(r["id"] == "abc" for r in rows)
|
||||
|
||||
|
||||
def test_persist_aircraft_snapshot_writes_tracks(monkeypatch):
|
||||
import asyncio
|
||||
|
||||
from live_layers import persist_aircraft_snapshot
|
||||
|
||||
recorded = []
|
||||
|
||||
async def fake_record(kind, marker):
|
||||
recorded.append((kind, marker["id"]))
|
||||
return True
|
||||
|
||||
async def fake_gf(**kw):
|
||||
return 0
|
||||
|
||||
monkeypatch.setattr("tracks.record_position", fake_record)
|
||||
monkeypatch.setattr("geofence.record_and_notify", fake_gf)
|
||||
monkeypatch.setattr("ws_manager.manager.has_clients", lambda: False)
|
||||
|
||||
rows = [{
|
||||
"id": "abc", "lat": 35.8, "lon": -78.7, "heading": 90, "speed": 400,
|
||||
"label": "ABC", "extra": {},
|
||||
}]
|
||||
asyncio.run(persist_aircraft_snapshot(rows))
|
||||
assert recorded == [("aircraft", "abc")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue