From e3b0b6f3dffa4237f2fbc3e49d443506306cd64a Mon Sep 17 00:00:00 2001 From: Audric Date: Sun, 24 May 2026 12:42:53 +0200 Subject: [PATCH] docs: refresh test docs and complete MsgTrunk* -> MsgPeer* rename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TWIN_PROTOCOL.md: note that the trunk->twin mirror delivers to selected AND monitoring clients (the composite selected-OR-monitor filter), pairing with the TwinLink fix in f1d4afd; complete the MsgTrunk* -> MsgPeer* rename in the steady-state message table and design narrative. - TESTS.md: bring in line with the current suite — trunk 35->50, twin 11->17. Document test_trunk 33-47 (satellite cross-visibility, prefix routing/cluster fanout, monitor-TG fanout, trunk resilience) and the test_twin X1-X5 series including the new X5 monitor regression; add the mqtt-deltas, satellite-secrets, and logging suites to the run sequence; update the five-client roster. - Rename stale MsgTrunk* references to MsgPeer* (wire IDs unchanged, per 18d92a2) across README, DEPLOYMENT_ITALY{,_IT}, WW_DEPLOYMENT, JAY-additions, and DESIGN_SATELLITE_AND_CLUSTER. PEER_PROTOCOL.md keeps its two MsgTrunk* mentions — they document the rename itself. --- README.md | 4 +- docs/DEPLOYMENT_ITALY.md | 2 +- docs/DEPLOYMENT_ITALY_IT.md | 2 +- docs/DESIGN_SATELLITE_AND_CLUSTER.md | 18 ++--- docs/JAY-additions.md | 8 +- docs/TWIN_PROTOCOL.md | 54 +++++++------ docs/WW_DEPLOYMENT.md | 2 +- tests/TESTS.md | 110 +++++++++++++++++++-------- 8 files changed, 126 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index 653fcd6..a5ec5f8 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ automatically. `[TRUNK_x]` section, with a shared filter syntax (exact, `24*` prefix, `2427-2438` range). Reloadable at runtime via the PTY admin channel - **Node-list broadcasting** — on local client login / logout / TG change the - reflector debounces (500 ms) and emits a `MsgTrunkNodeList` to every trunk + reflector debounces (500 ms) and emits a `MsgPeerNodeList` to every trunk peer (and, when configured, the `[TWIN]` partner) carrying callsign + current TG + optional lat/lon/QTH. Inbound lists from trunk peers or twin partners are republished via MQTT under `nodes/`, Redis under @@ -412,7 +412,7 @@ satellite and vice versa, regardless of `CLUSTER_TGS` or prefix configuration. **Opt-in TG scope via `SATELLITE_FILTER`.** Setting `SATELLITE_FILTER` on the satellite side restricts the link to a chosen set of TGs in both directions: the satellite suppresses its own outbound events for non-matching TGs, and -advertises the filter to the parent (via `MsgTrunkFilter`, type 122) so the +advertises the filter to the parent (via `MsgPeerFilter`, type 122) so the parent also stops forwarding non-matching TGs back. Empty or absent means no filtering. The filter uses the shared TG-filter syntax (exact, `24*` prefix, `2427-2438` range, comma-separated). diff --git a/docs/DEPLOYMENT_ITALY.md b/docs/DEPLOYMENT_ITALY.md index 5e1f269..2b9ebac 100644 --- a/docs/DEPLOYMENT_ITALY.md +++ b/docs/DEPLOYMENT_ITALY.md @@ -277,7 +277,7 @@ All reflectors in the mesh must list the same `CLUSTER_TGS` value. There is **no hardcoded limit** on concurrent QSOs over the trunk. The trunk between each pair of reflectors is a single TCP connection that multiplexes all -active TGs simultaneously — each `MsgTrunkAudio` frame is tagged with the TG +active TGs simultaneously — each `MsgPeerAudio` frame is tagged with the TG number, so any number of TGs can carry audio at the same time. The only per-TG rule is that **one talker is allowed per TG at a time** diff --git a/docs/DEPLOYMENT_ITALY_IT.md b/docs/DEPLOYMENT_ITALY_IT.md index 4f7a57d..4977573 100644 --- a/docs/DEPLOYMENT_ITALY_IT.md +++ b/docs/DEPLOYMENT_ITALY_IT.md @@ -284,7 +284,7 @@ Tutti i reflector nella mesh devono avere lo stesso valore di `CLUSTER_TGS`. Non esiste **nessun limite fisso** al numero di QSO simultanei sul trunk. Il trunk tra ogni coppia di reflector è una singola connessione TCP che multiplexa tutti i -TG attivi contemporaneamente — ogni frame `MsgTrunkAudio` è etichettato con il +TG attivi contemporaneamente — ogni frame `MsgPeerAudio` è etichettato con il numero di TG, quindi qualsiasi numero di TG può trasmettere audio nello stesso momento. L'unica regola per TG è che **un solo operatore alla volta può trasmettere su un diff --git a/docs/DESIGN_SATELLITE_AND_CLUSTER.md b/docs/DESIGN_SATELLITE_AND_CLUSTER.md index 7292a66..1725d7a 100644 --- a/docs/DESIGN_SATELLITE_AND_CLUSTER.md +++ b/docs/DESIGN_SATELLITE_AND_CLUSTER.md @@ -88,7 +88,7 @@ Similar to `TrunkLink` but with different semantics: | Aspect | TrunkLink (peer-to-peer) | SatelliteLink | |--------|-------------------------|---------------| | Topology | Symmetric mesh peers | Asymmetric — parent is authority | -| TG routing | Prefix-based (`isSharedTG`/`isOwnedTG`) + cluster (`isClusterTG`) | Unfiltered by default; optional `SATELLITE_FILTER` (bidirectional, advertised via `MsgTrunkFilter`) | +| TG routing | Prefix-based (`isSharedTG`/`isOwnedTG`) + cluster (`isClusterTG`) | Unfiltered by default; optional `SATELLITE_FILTER` (bidirectional, advertised via `MsgPeerFilter`) | | Talker arbitration | Nonce tie-break | Parent always wins | | Who initiates | Both sides connect to each other | Satellite connects to parent | | Audio path | Only prefix-matched + cluster TGs | All TGs active on either side | @@ -104,7 +104,7 @@ Similar to `TrunkLink` but with different semantics: (dynamically on accept, like `ReflectorClient`). 3. **Audio forwarding**: when a local client or trunk peer starts talking on any - TG, the parent also sends `MsgTrunkTalkerStart` + `MsgTrunkAudio` to all + TG, the parent also sends `MsgPeerTalkerStart` + `MsgPeerAudio` to all connected satellites. When a satellite client talks, the parent treats it identically to a local client — forwards to trunk peers via `isSharedTG` as normal. @@ -127,10 +127,10 @@ The satellite is a **thin relay**: #### Wire protocol Reuse the existing trunk message types (115-120). The satellite handshake -(`MsgTrunkHello`) includes a flag field so the parent knows to treat the +(`MsgPeerHello`) includes a flag field so the parent knows to treat the connection as a satellite rather than a mesh peer. -Add one field to `MsgTrunkHello`: +Add one field to `MsgPeerHello`: ```cpp uint8_t m_role; // 0 = PEER (default, backward-compatible), 1 = SATELLITE @@ -143,7 +143,7 @@ uint8_t m_role; // 0 = PEER (default, backward-compatible), 1 = SATELLITE | `Reflector.cpp` | Add satellite TCP server, accept satellite connections | | `SatelliteLink.cpp` (new) | Parent-side satellite connection handler | | `SatelliteClient.cpp` (new) | Satellite-side parent connection + local relay | -| `ReflectorMsg.h` | Add `m_role` to `MsgTrunkHello` | +| `ReflectorMsg.h` | Add `m_role` to `MsgPeerHello` | | `TrunkLink.cpp` | No changes — mesh unchanged | | `svxreflector.conf.in` | Add `[SATELLITE]`, `SATELLITE_OF` settings | @@ -265,11 +265,11 @@ void TrunkLink::onLocalTalkerStart(uint32_t tg, const std::string& callsign) { return; } - sendMsg(MsgTrunkTalkerStart(tg, callsign)); + sendMsg(MsgPeerTalkerStart(tg, callsign)); } ``` -Similarly for inbound: `handleMsgTrunkTalkerStart` and the other receive +Similarly for inbound: `handleMsgPeerTalkerStart` and the other receive handlers use `isOwnedTG` (checks both local and remote prefix) instead of `isSharedTG`, combined with `|| isClusterTG`: @@ -306,7 +306,7 @@ The `onTalkerUpdated` callback currently iterates all trunk links and calls individually decides whether to forward based on `isSharedTG || isClusterTG`. Audio forwarding in `Reflector::onTalkerUpdated` already loops all links. Same -for `handleMsgTrunkAudio` -> `broadcastUdpMsg` on the receiving side. +for `handleMsgPeerAudio` -> `broadcastUdpMsg` on the receiving side. #### Cluster TG validation at startup @@ -368,7 +368,7 @@ No new message types. No wire protocol changes. No new classes. |---|---|---| | **Solves** | Mesh scaling for large deployments | Shared nationwide channels | | **Complexity** | New class + new TCP listener | ~50 lines of routing logic changes | -| **Wire protocol** | 1 new field in MsgTrunkHello | No changes | +| **Wire protocol** | 1 new field in MsgPeerHello | No changes | | **Config** | `[SATELLITE]`, `SATELLITE_OF` | `CLUSTER_TGS=222,91` | | **Risk** | Medium — new connection type | Low — additive routing check | | **Recommended order** | Second | **First** (simpler, high value) | diff --git a/docs/JAY-additions.md b/docs/JAY-additions.md index aa8e77b..714a1b0 100644 --- a/docs/JAY-additions.md +++ b/docs/JAY-additions.md @@ -25,8 +25,8 @@ material that was not merged here. | Per-trunk config | `TG_MAP=peer:local,...` | Bidirectional TG remap; mapped TGs bypass the prefix routing check on this link | | Per-trunk config | `PEER_ID` | Stable identifier advertised in the trunk hello (defaults to section name); used as the MQTT topic component on the receiving side | | Global config | `MQTT_NAME` (in `[MQTT]`) | Appended to `TOPIC_PREFIX` so each reflector publishes under a unique sub-tree (`//...`) | -| Wire protocol | `MsgTrunkNodeList` (type **121**) | Periodic node list (callsign + current TG, plus optional lat/lon/QTH) sent peer-to-peer when the local client list changes; receiver re-publishes it via MQTT | -| Wire protocol | `MsgTrunkFilter` (type **122**) | Optional satellite-side TG-filter advertisement so a satellite can subscribe to only a subset of the parent's TGs | +| Wire protocol | `MsgPeerNodeList` (type **121**) | Periodic node list (callsign + current TG, plus optional lat/lon/QTH) sent peer-to-peer when the local client list changes; receiver re-publishes it via MQTT | +| Wire protocol | `MsgPeerFilter` (type **122**) | Optional satellite-side TG-filter advertisement so a satellite can subscribe to only a subset of the parent's TGs | | PTY commands | `TRUNK MUTE \| UNMUTE
` | Live mute of a callsign per trunk link; muted callsigns' inbound audio is dropped | | PTY commands | `TRUNK RELOAD [
]` | Re-reads `BLACKLIST_TGS`, `ALLOW_TGS`, `TG_MAP` from the live config without restarting | | PTY commands | `TRUNK STATUS [
]` | Dumps a one-line status summary per trunk link to the PTY | @@ -77,8 +77,8 @@ linked above and open an issue or PR on this repository. | File | What to look for | |------|------------------| | `src/svxlink/reflector/TgFilter.h` | Filter parser | -| `src/svxlink/reflector/ReflectorMsg.h` | `MsgTrunkNodeList` (121), `MsgTrunkFilter` (122) | -| `src/svxlink/reflector/TrunkLink.{h,cpp}` | Per-link filters, mapping, mute, `reloadConfig`, `statusLine`, `sendNodeList`, `handleMsgTrunkNodeList`, `peerId()` | +| `src/svxlink/reflector/ReflectorMsg.h` | `MsgPeerNodeList` (121), `MsgPeerFilter` (122) | +| `src/svxlink/reflector/TrunkLink.{h,cpp}` | Per-link filters, mapping, mute, `reloadConfig`, `statusLine`, `sendNodeList`, `handleMsgPeerNodeList`, `peerId()` | | `src/svxlink/reflector/Reflector.{h,cpp}` | `scheduleNodeListUpdate`, `sendNodeListToAllPeers`, `onPeerNodeList`, PTY `TRUNK` command branch, `MQTT_NAME` topic prefix | | `src/svxlink/reflector/MqttPublisher.{h,cpp}` | `publishLocalNodes`, `publishPeerNodes` | | `src/svxlink/reflector/svxreflector.conf.in` | Config-template documentation for every new key | diff --git a/docs/TWIN_PROTOCOL.md b/docs/TWIN_PROTOCOL.md index decd930..586fc93 100644 --- a/docs/TWIN_PROTOCOL.md +++ b/docs/TWIN_PROTOCOL.md @@ -2,7 +2,7 @@ > **Status:** Implemented in v1.3.x+twin2. See §Implementation for > what shipped and `tests/test_twin.py` for integration test coverage -> (11 tests including end-to-end V2-client audio mirroring and +> (17 tests including end-to-end V2-client audio mirroring and > partner-roster propagation into `/status.twin.nodes`). ## Motivation @@ -61,7 +61,7 @@ connect to either physical node. failure. This gives zero-holdoff failover at the cost of external peers needing to understand "paired hosts" in their trunk config. - Cross-twin talker arbitration reuses the existing priority-nonce - tie-break: the same 32-bit `priority` field from `MsgTrunkHello` + tie-break: the same 32-bit `priority` field from `MsgPeerHello` decides who wins when both twins' clients PTT the same TG at the same instant. - During a twin-link outage both twins keep operating fully and @@ -91,7 +91,7 @@ symmetric (like a trunk) and strictly 1:1 (unlike either). ### Handshake -Reuse `MsgTrunkHello` (type 115) with a new role value: +Reuse `MsgPeerHello` (type 115) with a new role value: ```cpp static const uint8_t ROLE_PEER = 0; // existing @@ -99,7 +99,7 @@ static const uint8_t ROLE_SATELLITE = 1; // existing static const uint8_t ROLE_TWIN = 2; // NEW ``` -Both sides send `MsgTrunkHello` with `role=ROLE_TWIN`, the shared +Both sides send `MsgPeerHello` with `role=ROLE_TWIN`, the shared `[TWIN]` section name as `id`, the common `LOCAL_PREFIX` as `local_prefix`, an HMAC over `secret`, and a fresh 32-bit `priority` nonce. @@ -124,14 +124,14 @@ filtering: | Type | Name | Purpose on twin link | |------|----------------------------|---------------------------------------------------| -| 115 | `MsgTrunkHello` | Handshake (role=ROLE_TWIN) | -| 116 | `MsgTrunkTalkerStart` | Mirror local-client talker start | -| 117 | `MsgTrunkTalkerStop` | Mirror local-client talker stop | -| 118 | `MsgTrunkAudio` | Mirror local-client audio | -| 119 | `MsgTrunkFlush` | Mirror end-of-stream | -| 120 | `MsgTrunkHeartbeat` | Keepalive (**2s TX / 5s RX** on twin links) | -| 121 | `MsgTrunkNodeList` | Mirror node roster so `/status` is consistent on both twins | -| 122 | `MsgTrunkFilter` | **Not used on twin links** — twins mirror every TG unconditionally. Reserved for satellite use. | +| 115 | `MsgPeerHello` | Handshake (role=ROLE_TWIN) | +| 116 | `MsgPeerTalkerStart` | Mirror local-client talker start | +| 117 | `MsgPeerTalkerStop` | Mirror local-client talker stop | +| 118 | `MsgPeerAudio` | Mirror local-client audio | +| 119 | `MsgPeerFlush` | Mirror end-of-stream | +| 120 | `MsgPeerHeartbeat` | Keepalive (**2s TX / 5s RX** on twin links) | +| 121 | `MsgPeerNodeList` | Mirror node roster so `/status` is consistent on both twins | +| 122 | `MsgPeerFilter` | **Not used on twin links** — twins mirror every TG unconditionally. Reserved for satellite use. | | 123 | `MsgTwinExtTalkerStart` | **NEW** — "my external trunk peer `` has claimed TG X with callsign Y"; receiver updates its `TGHandler` trunk-talker map so local clients on the partner twin cannot key up that TG | | 124 | `MsgTwinExtTalkerStop` | **NEW** — clears the corresponding external-talker state | @@ -145,7 +145,7 @@ to the correct external peer on reconnect/cleanup. ### Cross-twin talker arbitration -When `handleMsgTrunkTalkerStart` fires on a twin link, the receiver +When `handleMsgPeerTalkerStart` fires on a twin link, the receiver treats it like a trunk talker-start **with prefix filtering disabled**: any TG is accepted, and `TGHandler::setTrunkTalkerForTG(tg, callsign)` is called so local clients on the receiving twin cannot grab the talker @@ -155,9 +155,14 @@ priority-nonce rule (lower wins, loser yields via the existing ### Audio replication -`MsgTrunkAudio` on a twin link is broadcast to local clients on the +`MsgPeerAudio` on a twin link is broadcast to local clients on the matching TG via `Reflector::broadcastUdpMsg` — same as the trunk path, -but without the `isOwnedTG` gate. The twin does *not* re-forward the +but without the `isOwnedTG` gate. As on the trunk and satellite paths, +the broadcast reaches both clients with the TG **selected** and passive +**monitors** of it (the composite selected-OR-monitor filter, preserving +the passive-observer / earliest-monitor-talker arbitration); a plain +selected-only filter would silently drop monitor-only listeners on the +non-sticky twin (see `test_X5`). The twin does *not* re-forward the audio to its own external trunks (that would duplicate — external trunks are only held by the primary; see below). @@ -223,7 +228,7 @@ only on which twin the local client is physically connected to. ### Cross-twin external-talker state propagation -When a twin receives `MsgTrunkTalkerStart(tg=262xx, callsign=IW0ABC)` +When a twin receives `MsgPeerTalkerStart(tg=262xx, callsign=IW0ABC)` from refA on its sticky socket, it: 1. Updates its own `TGHandler` trunk-talker state as usual. @@ -245,9 +250,10 @@ forwards the audio across the twin link via satellite-to-twin mirror), reusing `MsgPeerAudio` on the [TWIN] socket. `TrunkLink::handleMsgPeerFlush` mirrors the matching flush. The receiving partner's `TwinLink::handleMsgPeerAudio` broadcasts to its -local clients on the TG and fans the audio out to its own satellites; -it does *not* re-forward to trunk peers, so there is no echo back to -refA. +local clients on the TG — both selected and passive-monitoring, using +the same composite filter as the trunk path (see `test_X5`) — and fans +the audio out to its own satellites; it does *not* re-forward to trunk +peers, so there is no echo back to refA. ### refA-side socket selection policy @@ -371,7 +377,7 @@ Where the pieces live in the source tree: the twin link can be cleaned up per-peer on disconnect without clobbering other peers' claims. - **`ReflectorMsg.h`** adds types 123 / 124 (`MsgTwinExtTalkerStart` - / `Stop`) and a new `ROLE_TWIN = 2` value on `MsgTrunkHello`. + / `Stop`) and a new `ROLE_TWIN = 2` value on `MsgPeerHello`. - **`svxreflector.conf.in`** includes commented-out `[TWIN]` and `PAIRED=1` examples. - **`tests/test_twin.py`** covers handshake, PAIRED trunk wiring, @@ -393,19 +399,19 @@ Artifacts that can occur while the twin link is down: - A German client on ref1 and a different German client on ref2 can both PTT TG 262xx at the same time. Each twin is unaware of the - other's talker and both forward `MsgTrunkTalkerStart` to refA over + other's talker and both forward `MsgPeerTalkerStart` to refA over their own external sockets. refA will receive conflicting talker-starts on its two endpoints for the same logical trunk. Resolution: refA's sticky routing means it accepts whichever it sees first and the other twin's forwarded audio lands on the non-sticky socket; the non-sticky-side audio is dropped by refA's "audio only from the peer that claimed the TG" check (same rule - already used inside `handleMsgTrunkAudio` today). + already used inside `handleMsgPeerAudio` today). - External-talker state set on one twin is not mirrored to the other, so the partner twin may accept a local-client PTT that would otherwise have been blocked. The resulting audio flows to refA and may compete with the existing conversation. Outcome depends on - refA's sticky choice and the `handleMsgTrunkAudio` talker check. + refA's sticky choice and the `handleMsgPeerAudio` talker check. These artifacts are bounded to the duration of the twin-link outage and heal automatically on reconnection: once the twin link is back, @@ -435,7 +441,7 @@ Summary of the key design choices and why they were made: | External-talker state sync | **Full `TGHandler` state mirrored** via `MsgTwinExtTalkerStart/Stop` | Unified view on both twins so local PTT is blocked when external peer holds a TG | | Audio transport twin↔twin | **TCP relay**, same framing as trunk | Works anywhere, no new cipher/auth story, bandwidth fine for 1:1 | | Heartbeat cadence on twin link | **2s TX / 5s RX** | Twins LAN-close, fast `/status` convergence | -| `MsgTrunkNodeList` | Each twin advertises **only its own local clients** externally; twin link mirrors the roster internally for consistent `/status` on both twins | Connection identity on the external peer provides origin; no additive schema change to `MsgTrunkNodeList` needed | +| `MsgPeerNodeList` | Each twin advertises **only its own local clients** externally; twin link mirrors the roster internally for consistent `/status` on both twins | Connection identity on the external peer provides origin; no additive schema change to `MsgPeerNodeList` needed | | Redis config store | **No changes** | Role is runtime state, not config; shared config already syncs via Redis | | Naming | **`[TWIN]`** | Short, clear, orthogonal to `[TRUNK_x]` / `[SATELLITE]` | diff --git a/docs/WW_DEPLOYMENT.md b/docs/WW_DEPLOYMENT.md index 8200d3a..8eada40 100644 --- a/docs/WW_DEPLOYMENT.md +++ b/docs/WW_DEPLOYMENT.md @@ -333,7 +333,7 @@ will broadcast it to all of its trunk peers. There is **no hardcoded limit** on concurrent QSOs over the trunk. The trunk between each pair of reflectors is a single TCP connection that multiplexes -all active TGs simultaneously — each `MsgTrunkAudio` frame is tagged with the +all active TGs simultaneously — each `MsgPeerAudio` frame is tagged with the TG number, so any number of TGs can carry audio at the same time. The only per-TG rule is that **one talker is allowed per TG at a time** diff --git a/tests/TESTS.md b/tests/TESTS.md index 225f0ce..f424111 100644 --- a/tests/TESTS.md +++ b/tests/TESTS.md @@ -5,8 +5,10 @@ The integration tests verify the trunk protocol, satellite links, twin (HA-pair) protocol, Redis-backed config store, and end-to-end audio routing by spinning up reflector meshes in Docker Compose and connecting fake peers and clients from a Python test harness. `run_tests.sh` runs in **two phases**: -1. A 3-reflector trunk mesh + a satellite-mode reflector exercising `test_trunk.py` (35 tests). -2. A 4-reflector twin topology exercising `test_twin.py` (11 tests). +1. A 3-reflector trunk mesh + a satellite-mode reflector, exercising + `test_trunk.py` (50 tests), `test_mqtt_deltas.py` (7 tests), + `test_satellite_secrets.py` (5 tests), and `test_logging.py` (6 tests). +2. A 4-reflector twin topology exercising `test_twin.py` (17 tests). A separate harness (`run_redis_tests.sh`) runs `test_redis.py` (13 tests) against a single-reflector + Redis stack. See [Redis Integration Tests](#redis-integration-tests) below. @@ -21,13 +23,11 @@ bash run_tests.sh This will: 1. Generate the default configs and `docker-compose.test.yml` from `topology.py` -2. Build and start the 3-reflector mesh -3. Run 35 automated trunk/satellite/MQTT tests (`test_trunk.py`) -4. Enter an interactive prompt to manually test any TG number -5. Tear down the default mesh -6. Regenerate with `--topology twin` (4-reflector twin topology) -7. Rebuild the mesh and run 11 automated twin-protocol tests (`test_twin.py`) -8. Restore the default topology files and tear everything down +2. Build and start the 3-reflector mesh (+ a satellite-mode reflector) +3. Run `test_trunk.py` (50), then `test_mqtt_deltas.py` (7), `test_satellite_secrets.py` (5), and `test_logging.py` (6). When run in a terminal, `test_trunk.py` ends with an interactive TG prompt (see [Interactive Mode](#interactive-mode)) before the other suites run +4. Tear down the default mesh and regenerate with `--topology twin` (4-reflector twin topology) +5. Rebuild the mesh and run `test_twin.py` (17 twin-protocol tests) +6. Restore the default topology files and tear everything down To regenerate configs without running tests: @@ -55,13 +55,15 @@ Two fake trunk peers connect from the test harness: - **TRUNK_TEST** (prefix `9`) — primary sender for most tests - **TRUNK_TEST_RX** (prefix `8`) — passive receiver for isolation tests -Three V2 clients are configured on every reflector: -- **N0TEST** / **N0SEND** / **N0THRD** (group `TestGroup`, password `testpass`) +Five V2 clients are configured on every reflector: +- **N0TEST** / **N0SEND** / **N0THRD** / **N0FOUR** / **N0FIVE** (group `TestGroup`, password `testpass`) -Three distinct callsigns are required for the 3-way mesh tests: when two -non-owner reflectors both forward `MsgTrunkTalkerStart` to the owner with -the same callsign, the owner's per-TG trunk-talker slot cannot tell them -apart. +At least three distinct callsigns are required for the 3-way mesh tests: +when two non-owner reflectors both forward `MsgPeerTalkerStart` to the +owner with the same callsign, the owner's per-TG trunk-talker slot cannot +tell them apart. The twin monitor test (`test_X5`) needs five distinct +clients — a selecting and a monitoring receiver on each twin, plus a +sender. A satellite server is enabled on reflector-a (port 5303, secret `sat_secret`). A real satellite-mode reflector (`reflector-sat`, `SATELLITE_OF=reflector-a`) also runs in the compose so tests can verify satellite-mode behavior end-to-end (e.g. that MQTT publishing still works). @@ -119,8 +121,11 @@ Internal port for `[TWIN]` is always 5304; satellite is 5303. |------|---------| | `topology.py` | Single source of truth — prefixes, ports, secrets, cluster TGs, test clients. Contains both the default mesh (`REFLECTORS`) and the `TWIN_REFLECTORS` / `TWIN_TRUNKS` definitions. | | `generate_configs.py` | Generates `configs/*.conf` and `docker-compose.test.yml` from topology. Supports `--topology default` (implicit) and `--topology twin`. | -| `test_trunk.py` | Test harness: fake trunk peers, satellite peer, V2 client, 35 test cases, interactive loop. | -| `test_twin.py` | TWIN-protocol tests (10 cases) using the twin topology. Reuses `ClientPeer` and `SatellitePeer` from `test_trunk.py`. | +| `test_trunk.py` | Test harness: fake trunk peers, satellite peer, V2 client, 50 test cases, interactive loop. | +| `test_mqtt_deltas.py` | Peer-client liveness MQTT delta tests (7 cases): per-client connect/disconnect/rx events published as `peer//client//`, across the satellite axis and trunk-peer non-propagation. Runs on the default mesh. | +| `test_satellite_secrets.py` | Per-satellite secret resolver tests (5 cases): `SECRET_` match accepts, mismatch rejects with no fallback, unknown id falls back to `[SATELLITE].SECRET`. Runs on the default mesh. | +| `test_logging.py` | Logging-facade (`geulog::`) tests (6 cases): `LOG` PTY commands (SHOW/SET/RESET), level filtering, error rejection via the `/dev/shm/reflector_ctrl` PTY. Runs on the default mesh. | +| `test_twin.py` | TWIN-protocol tests (17 cases) using the twin topology. Reuses `ClientPeer` and `SatellitePeer` from `test_trunk.py`. | | `run_tests.sh` | Orchestrator: generate → build → trunk tests → teardown → regenerate twin → build → twin tests → teardown. | | `configs/` | Generated reflector config files (do not edit manually) | | `docker-compose.test.yml` | Generated compose file (do not edit manually) | @@ -177,7 +182,7 @@ Simulates a V2 SvxLink client. Performs the full TCP authentication handshake (P | 14 | Satellite receives from parent | Trunk talker audio on the parent is forwarded to the satellite | | 15 | Satellite audio to trunk peer | Satellite sends audio for a TG owned by another reflector; parent forwards via trunk | | 16 | Satellite disconnect cleanup | Abrupt satellite disconnect clears it from `/status` | -| 16b | Satellite TG filter honored by parent | Satellite sends `MsgTrunkFilter` (type 122) after hello; parent forwards the matching cluster TG but drops the non-matching one | +| 16b | Satellite TG filter honored by parent | Satellite sends `MsgPeerFilter` (type 122) after hello; parent forwards the matching cluster TG but drops the non-matching one | | 16c | Satellite filter visible in `/status` | Active filter surfaces as `satellites[].filter`; key absent when unset, appears after send, clears after empty filter | ### Bidirectional and Multi-Way Routing @@ -207,7 +212,7 @@ each filter independently of the other trunk fixtures. | # | Test | What it verifies | |---|------|-----------------| -| 19 | `PEER_ID` in hello | Reflector advertises the configured `PEER_ID` (not the section name) in `MsgTrunkHello` | +| 19 | `PEER_ID` in hello | Reflector advertises the configured `PEER_ID` (not the section name) in `MsgPeerHello` | | 20 | `BLACKLIST_TGS` drops TG | TalkerStart on a blacklisted TG is dropped (not in `/status` active talkers) | | 21 | `ALLOW_TGS` whitelist | TG matching the whitelist passes; TG outside is dropped | | 22 | `TG_MAP` remap | TalkerStart on wire TG `7000` is remapped and tracked as local TG `1220` | @@ -219,26 +224,67 @@ each filter independently of the other trunk fixtures. | # | Test | What it verifies | |---|------|-----------------| -| 27 | `MsgTrunkNodeList` emission | Connecting a V2 client triggers a debounced node-list send to trunk peers; the harness receives a `MsgTrunkNodeList` (type 121) containing the new client | +| 27 | `MsgPeerNodeList` emission | Connecting a V2 client triggers a debounced node-list send to trunk peers; the harness receives a `MsgPeerNodeList` (type 121) containing the new client | | 27b | Trunk peer roster in `/status` | A client authenticated on the primary reflector appears in a peer's `/status.trunks[SECTION].nodes`; disappears after disconnect | +### Satellite Cross-Visibility + +| # | Test | What it verifies | +|---|------|-----------------| +| 33 | Sat-attached client on parent `/status` | A V2 client attached to the satellite reflector appears in the parent's `/status.satellites[].nodes` | +| 34 | Sat-attached client on trunk peer | The same client appears on a far trunk peer's `/status.trunks[
].nodes` with the `sat_id` field set, proving sat → parent → trunk roster propagation | +| 35 | Parent-local client on satellite `/status` | A client on the parent appears on the satellite's `/status.satellite.parent_nodes`, proving the parent → satellite direction | +| 36 | Multi-satellite cross-visibility | Two satellites on the same parent each see the other's roster contribution, `sat_id`-stamped to identify the originator | + +### Prefix Routing and Cluster Fanout + +| # | Test | What it verifies | +|---|------|-----------------| +| 37 | Gateway prefix routing | Audio crosses two trunk legs via a non-owner gateway with no `CLUSTER_TGS` involved — pure longest-prefix-match (`shouldRelayInbound` → gateway forward) | +| 38 | Cluster-TG local-client broadcast | A local V2 client keys a cluster TG; a V2 client on another reflector selecting that TG hears it, via `onLocalAudio` cluster fanout regardless of prefix | + +### Monitor-TG Audio Fanout + +| # | Test | What it verifies | +|---|------|-----------------| +| 39 | Passive monitor multi-hop | A passive monitor on reflector-a hears a TG owned by reflector-d through reflector-b as gateway, without ever PTT'ing — interest bootstrapped via `MsgPeerTgInterest` | +| 40 | Monitor does not mix with selected TG | Regression for the v1.3.10 mixing bug: with `SELECT_TG=9` and `MONITOR_TGS=[110]`, a busy selected TG suppresses the monitor TG's audio | +| 41 | Priority switch still works | When svxlink switches to a higher-priority monitor TG (`MsgSelectTG`) while the selected TG is idle, the reflector routes the switched TG correctly | +| 42 | Passive observer unaffected | A client with `select_tg(0)` + one monitor TG still receives that monitor TG's UDP audio (guards the `tg == 0` short-circuit in `SelectedTgIdleFilter`) | +| 43 | Multi-monitor blocked when selected set | With `currentTG=9` and two busy monitor TGs, the client receives zero UDP audio for either — the monitor arm only opens when `currentTG == 0` | +| 44 | Passive-observer no monitor mix | First-talker-wins invariant for a passive observer (`currentTG=0`) across multiple monitor talkers | +| 45 | Monitor blocked when selected set | Contract: with a non-zero selected TG, the client receives no UDP audio for any monitored TG | + +### Trunk Resilience + +| # | Test | What it verifies | +|---|------|-----------------| +| 46 | Inbound heartbeat timeout — no crash | A non-paired trunk link whose inbound socket is closed on heartbeat timeout must not abort the process on the next send (e.g. a `MsgPeerTgInterest`) | +| 47 | Inbound recovers after timeout | After the reflector times out and drops a silent inbound peer, the same peer can reconnect its inbound leg | + ### Twin Protocol (HA-pair) Run separately on the twin topology (`test_twin.py`). See `docs/TWIN_PROTOCOL.md` for the protocol. | # | Test | What it verifies | |---|------|-----------------| -| 1 | TWIN handshake | Both ref1 and ref2 log a successful `TWIN: hello from partner` with authentication | -| 2 | No auth errors | Neither twin emits HMAC or `local_prefix` mismatch errors on startup | -| 3 | PAIRED trunk on refa | refa's single `[TRUNK_IT_DE]` (PAIRED=1) reports `connected=True` with both hosts reachable | -| 4 | PAIRED return leg | ref1 and ref2 each see their own `[TRUNK_IT_DE]` back to refa as connected | -| 5 | No twin-setup errors | Startup logs on both twins contain no `ERROR[TWIN]` lines | -| 6 | Twin disconnect recovery | Killing ref2 triggers an RX timeout on ref1; restarting ref2 re-handshakes cleanly | -| 7 | PAIRED trunk failover | Killing ref1 does **not** disconnect refa's `[TRUNK_IT_DE]` — sticky selection fails over to ref2 without holdoff | -| 8 | Audio mirror end-to-end | A V2 client on ref1 transmits on TG 26201; a V2 client on ref2 receives UDP audio and a flush marker, exercising the full `TGHandler.talkerUpdated` → `TwinLink.onLocalAudio` → `MsgTrunkAudio` → `broadcastUdpMsg` path | -| 9 | Satellite + twin handshake | A satellite connects to ref1 (the `TWIN_SATELLITE_PARENT`) and is listed in `/status.satellites` after the two-way hello | -| 10 | Satellite sees twin-mirrored audio | A V2 client on ref2 transmits on TG 26201; the satellite attached to ref1 receives `TalkerStart` and `MsgTrunkAudio` — verifies `TwinLink::handleMsgTrunkAudio` re-forwards to satellites, not just talker state | -| 11 | Twin partner roster in `/status` | A V2 client authenticated on ref1 appears under ref2's `/status.twin.nodes`; disappears after disconnect. Exercises `MsgTrunkNodeList` over the `[TWIN]` socket and `TwinLink::m_partner_nodes` | +| 01 | TWIN handshake | Both ref1 and ref2 report a completed `TWIN: hello from partner` exchange in `/status` | +| 02 | No auth errors | Neither twin emits HMAC or `local_prefix` mismatch errors; `[TWIN]` SECRET and LOCAL_PREFIX are consistent | +| 03 | PAIRED trunk on refa | refa's single `[TRUNK_IT_DE]` (PAIRED=1, two hosts) reaches `connected=True` | +| 04 | PAIRED return leg | ref1 and ref2 each see their own `[TRUNK_IT_DE]` back to refa as connected | +| 05 | No twin-setup errors | Both twins have a listening twin server and no `ERROR[TWIN]` (inbound evidence from `/status`) | +| 06 | Twin disconnect recovery | Killing ref2 triggers an RX timeout on ref1; restarting ref2 re-handshakes cleanly | +| 07 | PAIRED trunk failover | Killing ref1 does **not** disconnect refa's `[TRUNK_IT_DE]` — sticky selection fails over to ref2 without holdoff | +| 08 | Audio mirror between twins | A V2 client on ref1 transmits; a client on ref2 receives UDP audio + flush via `TGHandler.talkerUpdated` → `TwinLink.onLocalAudio` → `MsgPeerAudio` → `broadcastUdpMsg` | +| 09 | Satellite + twin handshake | A satellite connects to ref1 (the `TWIN_SATELLITE_PARENT`) and is listed in `/status.satellites` after the two-way hello | +| 10 | Satellite sees twin-mirrored audio | A V2 client on ref2 transmits; the satellite attached to ref1 receives `TalkerStart` + `MsgPeerAudio` — verifies the twin mirror re-forwards to satellites, not just talker state | +| 11 | Twin partner roster in `/status` | A V2 client on ref1 appears under ref2's `/status.twin.nodes`; disappears after disconnect. Exercises `MsgPeerNodeList` over the `[TWIN]` socket and `TwinLink::m_partner_nodes` | +| 12 | Twin heartbeat recovery | Pausing ref2 stalls heartbeats but keeps TCP alive; ref1 times out, re-arms its dialer, and reconnects when ref2 resumes | +| X1 | Per-client visible across twin | A V2 client connecting to ref1 causes ref2's MQTT broker to emit `peer/TWIN/client//connected` within 2 s | +| X2 | `MQTT_NAME` required in twin mode | A reflector with `[TWIN]` configured but missing/empty `MQTT_NAME` exits non-zero and logs `MQTT_NAME is required` | +| X3 | Satellite TX reaches twin partner | A satellite-client transmits via `SatelliteLink` to ref1; the twin partner ref2 delivers the audio to its local clients | +| X4 | PAIRED inbound reaches both twins | A client on refa transmits on a **262-prefixed** (twin-owned) TG; clients on ref1 **and** ref2 both receive UDP audio — the trunk→twin mirror covers the non-sticky twin | +| X5 | PAIRED inbound (owner TG) reaches monitoring twin clients | Mirror image of X4: refa transmits on a **refa-owned** (222) TG with the twins as subscribers; selecting **and** monitoring clients on both twins must hear it. Regression guard for the trunk→twin mirror using the composite selected-OR-monitor filter (not selected-only) | ## Redis Integration Tests @@ -267,7 +313,7 @@ Each test writes directly to Redis via `redis-cli` inside the container, publish | 6d | `live:trunk` carries status blob | `live:trunk:
.status` is a serialized `TrunkLink::statusJson()` (host, port, connected, local/remote prefix, active_talkers, muted) | | 7 | Outage + resync | Stopping Redis keeps existing clients connected; on restart the reflector logs `config.changed: all` and accepts newly-written users | | 8 | `--import-conf-to-redis` idempotent | Running the importer twice against the same `.conf` produces identical keyspace dumps | -| 9 | Peer node list populates + diffs | Inbound `MsgTrunkNodeList` creates `live:peer_node:
:` hashes; a shrunk follow-up list DELs dropped callsigns and updates mutated fields (e.g. `tg`) | +| 9 | Peer node list populates + diffs | Inbound `MsgPeerNodeList` creates `live:peer_node:
:` hashes; a shrunk follow-up list DELs dropped callsigns and updates mutated fields (e.g. `tg`) | | 10 | Peer node strings sanitized | Control chars and `:` are stripped from `callsign`/`qth`, oversized callsigns truncated to 32, entries whose callsign becomes empty are dropped, and non-finite / out-of-range lat/lon are cleared while keeping the callsign | | 11 | Peer nodes cleared on disconnect | Closing the trunk link with no other direction active DELs all `live:peer_node:
:*` keys for that peer | | 12 | Dynamic trunk add/remove | Writing a `trunk:
:peer` hash + publish logs `Added trunk link: …`; deleting it logs `Removed trunk link: …` |