mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 00:50:46 +08:00
feat(ume): expose WSS runtime logs on subscription status UI
Ring-buffer ws_logs API, alarm raise/clear labels with alarmkey, and scrollable log panel on UME page. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
635cd52d4f
commit
5bd83c58dc
6 changed files with 203 additions and 31 deletions
|
|
@ -16,9 +16,11 @@ from netx_api import ume_alarm_ws
|
|||
from netx_api.models import UmeAlarmSubscription
|
||||
from netx_api.ume_alarm_subscription_store import clear_subscription, load_subscription, save_subscription
|
||||
from netx_api.ume_alarm_ws import (
|
||||
append_ws_log,
|
||||
cancel_alarm_subscription_manual,
|
||||
establish_alarm_subscription_manual,
|
||||
get_subscription_status,
|
||||
get_ws_logs,
|
||||
load_persisted_subscription,
|
||||
parse_subscription_id_from_already_exists_error,
|
||||
process_alarm_notification,
|
||||
|
|
@ -736,6 +738,22 @@ class UmeAlarmNotificationTests(unittest.TestCase):
|
|||
self.assertTrue(changed)
|
||||
self.assertIsNone(self.db.get(UmeAlarmCurrent, "AK-CLEARED-1"))
|
||||
|
||||
def test_ws_log_ring_buffer(self):
|
||||
from netx_api import ume_alarm_ws as ws_mod
|
||||
|
||||
with ws_mod._WS_LOG_LOCK:
|
||||
ws_mod._WS_LOG_ENTRIES.clear()
|
||||
try:
|
||||
for i in range(5):
|
||||
append_ws_log(f"line-{i}")
|
||||
logs = get_ws_logs(limit=3)
|
||||
self.assertEqual(len(logs), 3)
|
||||
self.assertEqual(logs[-1]["message"], "line-4")
|
||||
self.assertIn("ts", logs[0])
|
||||
finally:
|
||||
with ws_mod._WS_LOG_LOCK:
|
||||
ws_mod._WS_LOG_ENTRIES.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