mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 00:50:46 +08:00
fix(ume): dedupe WSS logs on disconnect and unchanged alarms
Throttle repeated connection-state logs, skip unchanged alarm notifications, and suppress duplicate subscription-lost and parse-ignore messages. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
dba8d38f5c
commit
1784d996dd
2 changed files with 117 additions and 11 deletions
|
|
@ -808,7 +808,7 @@ class UmeAlarmNotificationTests(unittest.TestCase):
|
|||
ws_mod._WS_LOG_ENTRIES.clear()
|
||||
try:
|
||||
for i in range(5):
|
||||
append_ws_log(f"line-{i}")
|
||||
append_ws_log(f"line-{i}", dedup=False)
|
||||
logs = get_ws_logs(limit=3)
|
||||
self.assertEqual(len(logs), 3)
|
||||
self.assertEqual(logs[-1]["message"], "line-4")
|
||||
|
|
@ -817,6 +817,25 @@ class UmeAlarmNotificationTests(unittest.TestCase):
|
|||
with ws_mod._WS_LOG_LOCK:
|
||||
ws_mod._WS_LOG_ENTRIES.clear()
|
||||
|
||||
def test_ws_log_dedup_suppresses_repeat(self):
|
||||
from netx_api import ume_alarm_ws as ws_mod
|
||||
|
||||
with ws_mod._WS_LOG_LOCK:
|
||||
ws_mod._WS_LOG_ENTRIES.clear()
|
||||
with ws_mod._LOG_DEDUP_LOCK:
|
||||
ws_mod._LOG_DEDUP_CACHE.clear()
|
||||
try:
|
||||
append_ws_log("same-line", dedup_cooldown_s=60.0)
|
||||
append_ws_log("same-line", dedup_cooldown_s=60.0)
|
||||
logs = get_ws_logs()
|
||||
self.assertEqual(len(logs), 1)
|
||||
self.assertEqual(logs[0]["message"], "same-line")
|
||||
finally:
|
||||
with ws_mod._WS_LOG_LOCK:
|
||||
ws_mod._WS_LOG_ENTRIES.clear()
|
||||
with ws_mod._LOG_DEDUP_LOCK:
|
||||
ws_mod._LOG_DEDUP_CACHE.clear()
|
||||
|
||||
def test_parse_subscription_id_from_already_exists_error(self):
|
||||
msg = (
|
||||
'ume_request_failed:400:{"error":{"errorInfo":"topic subscription already exist, '
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue