trunk: expose peer roster in /status.trunks[SECTION].nodes
Cache the most recent sanitized MsgTrunkNodeList per TrunkLink in m_partner_nodes and surface it from statusJson() as trunks[X].nodes. /status now matches the roster that was already flowing to MQTT (nodes/<peer_id>) and Redis (pushPeerNode). Cleared when the link goes fully inactive — single, paired inbound, and paired outbound disconnect paths all check isActive() before clearing so a single surviving inbound/outbound in a paired group keeps the cache live. Redis tombstones are already handled by Reflector::onTrunkStateChanged() and unchanged here. Caveat (pre-existing): in PAIRED mode the two sources share one peerId(), so the latest arrival overwrites the prior one — same behaviour MQTT and Redis already have. Fixing that requires per-connection peer_id attribution, out of scope for this patch.
This commit is contained in:
1 parent
cadc5c5aa2
commit
bf5af3eca0
3 files changed
+73
No files matched your search
@@ -1706,6 +1706,49 @@ class TestTrunkIntegration(unittest.TestCase):
|
||||
finally:
|
||||
rx.close()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Test 27b: Trunk peer's roster visible in /status.trunks[X].nodes
|
||||
# ------------------------------------------------------------------
|
||||
def test_27b_trunk_peer_roster_in_status(self):
|
||||
"""A client logged in on the primary reflector appears under
|
||||
/status.trunks.<SECTION>.nodes on a trunk peer — symmetric with the
|
||||
twin-partner roster (trunks should expose the same info we already
|
||||
push to MQTT and Redis).
|
||||
"""
|
||||
# Pick any peer that trunks to the primary
|
||||
peer = next(n for n in REFLECTOR_NAMES if n != self.PRIMARY)
|
||||
section = T.trunk_section_name(peer, self.PRIMARY)
|
||||
|
||||
client = ClientPeer()
|
||||
try:
|
||||
port = T.mapped_client_port(self.PRIMARY)
|
||||
client.connect(HOST, port)
|
||||
client.authenticate(callsign=CLIENT_CALLSIGN,
|
||||
password=CLIENT_PASSWORD)
|
||||
|
||||
def callsign_on_peer():
|
||||
status = get_status(*_http(peer))
|
||||
trunk = status.get("trunks", {}).get(section, {})
|
||||
nodes = trunk.get("nodes", [])
|
||||
return any(n.get("callsign") == CLIENT_CALLSIGN for n in nodes)
|
||||
|
||||
wait_until(callsign_on_peer, timeout=5.0, interval=0.25,
|
||||
msg=f"{CLIENT_CALLSIGN} did not appear in {peer}'s "
|
||||
f"/status.trunks.{section}.nodes after login on "
|
||||
f"{self.PRIMARY}")
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
def callsign_gone_from_peer():
|
||||
status = get_status(*_http(peer))
|
||||
trunk = status.get("trunks", {}).get(section, {})
|
||||
nodes = trunk.get("nodes", [])
|
||||
return not any(n.get("callsign") == CLIENT_CALLSIGN for n in nodes)
|
||||
|
||||
wait_until(callsign_gone_from_peer, timeout=5.0, interval=0.25,
|
||||
msg=f"{CLIENT_CALLSIGN} still in {peer}'s "
|
||||
f"/status.trunks.{section}.nodes after disconnect")
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Test 28: MQTT client connect/disconnect events
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user