Re-home a short local talk group (e.g. 8) under the reflector's own owned prefix as a globally-unique number (e.g. 2620008) via a single [GLOBAL] LOCAL_ALIASES entry, so it routes across the trunk mesh like any owned TG while local users keep dialing the short number. - Config: LOCAL_ALIASES=localTG:aliasTG[/dir] (dir in|out, omitted = two-way); aliasTG must be owned by a LOCAL_PREFIX. Rejects unowned alias, an owned short side, duplicate short keys, and numeric overflow. - Boundary rewrite: prefix routing / owner-relay / peer-interest run on the long owned number; local delivery and talker arbitration run on the short number, bridged in the four inbound trunk handlers. - Rewrite-on-select folds a client that dials the long number onto the short number (select + monitor), so the two are one conversation locally and on the mesh. - Twin: external-talker notify uses the short number to match the audio mirror; disconnect cleanup folds to short so an aliased TG cannot wedge. - /status exposes local_aliases; satellite nodes warn that the setting is ignored (a local alias belongs on the mesh parent that owns the prefix). - Docs (PEER_PROTOCOL, CONCEPTS, conf template) and integration tests (tests/test_alias.py): two-way / in / out, rewrite-on-select, status, validation, disconnect-wedge, and duplicate-key coverage.
30 KiB
Integration Test Suite
Overview
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 three phases (98 tests total):
- A 3-reflector trunk mesh + a satellite-mode reflector, exercising
test_trunk.py(52 tests),test_alias.py(9 tests),test_mqtt_deltas.py(7 tests),test_satellite_secrets.py(5 tests), andtest_logging.py(6 tests). - A 4-reflector twin topology exercising
test_twin.py(17 tests). - A dedicated routable-prefix chain exercising
test_routable.py(2 tests). See Routable Prefixes below.
A separate harness (run_redis_tests.sh) runs test_redis.py (13 tests) against a single-reflector + Redis stack. See Redis Integration Tests below.
Requirements: Docker, Docker Compose, Python 3.7+ (stdlib only, no pip packages).
Running
cd tests
bash run_tests.sh
This will:
- Generate the default configs and
docker-compose.test.ymlfromtopology.py - Build and start the 3-reflector mesh (+ a satellite-mode reflector)
- Run
test_trunk.py(52), thentest_alias.py(9),test_mqtt_deltas.py(7),test_satellite_secrets.py(5), andtest_logging.py(6). When run in a terminal,test_trunk.pyends with an interactive TG prompt (see Interactive Mode) before the other suites run - Tear down the default mesh and regenerate with
--topology twin(4-reflector twin topology) - Rebuild the mesh and run
test_twin.py(17 twin-protocol tests) - Tear down the twin mesh, regenerate with
--topology routable, bring updocker-compose.routable.yml, and runtest_routable.py(2 tests) - Restore the default topology files and tear everything down
To regenerate configs without running tests:
python3 generate_configs.py # default 3-reflector mesh
python3 generate_configs.py --topology twin # 4-reflector twin topology
python3 generate_configs.py --topology routable # 4-node routable-prefix chain
Test Mesh Topology
Three reflectors form a full-mesh trunk network:
reflector-a (prefix 122) ◄──► reflector-b (prefix 121)
▲ ▲
└──────── reflector-c ─────────┘
(prefix 1)
Prefix ownership determines routing. TG 12200 belongs to reflector-a (prefix 122), TG 12100 to reflector-b (121), and TG 1000 to reflector-c (1) — unless a longer prefix matches first. For example, 122xx matches reflector-a even though reflector-c's prefix 1 is also a prefix of 122xx, because longest-prefix-match wins.
Cluster TGs (222, 999) are broadcast to all peers regardless of prefix ownership.
Local aliases (reflector-a only): LOCAL_ALIASES=8:1220008,90:1220090/out,91:1220091/in re-homes three short local TGs under a's own prefix 122 — see Local Aliases below and test_alias.py.
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
Five V2 clients are configured on every reflector:
- N0TEST / N0SEND / N0THRD / N0FOUR / N0FIVE (group
TestGroup, passwordtestpass)
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).
All test configs have TRUNK_DEBUG=1 enabled for verbose trunk logging during test runs.
Port Mapping
| Reflector | Client (TCP+UDP) | Trunk (TCP) | HTTP | Satellite |
|---|---|---|---|---|
| a | 15300 | 15302 | 18080 | 15303 |
| b | 25300 | 25302 | 28080 | — |
| c | 35300 | 35302 | 38080 | — |
| sat | 55300 | — | 58080 | — |
Internal ports inside Docker are always 5300, 5302, 8080, 5303.
Twin Test Topology
The twin topology (--topology twin) exercises the TWIN HA-pair protocol and PAIRED=1 external trunks. See docs/TWIN_PROTOCOL.md for the protocol specification.
satellite (ref1 only)
│
▼
refa (prefix 222)
│
│ [TRUNK_IT_DE] PAIRED=1 (one section, both hosts)
│ ┌───────────────┐
▼ ▼
ref1 ◄── [TWIN] ──► ref2 (both LOCAL_PREFIX=262)
│ │
└─── refc ───────────┘
(prefix 333, [TRUNK_DE_C] PAIRED=1 to the pair)
- refa (IT,
LOCAL_PREFIX=222) — the non-pair side; its single[TRUNK_IT_DE]lists both German hosts and uses sticky per-transmission selection with instant failover. - ref1, ref2 (DE,
LOCAL_PREFIX=262on both) — the twin pair, linked by a[TWIN]section on port 5304 and sharingTGHandlerstate. - refc (
LOCAL_PREFIX=333) — extra peer. Its[TRUNK_DE_C]is alsoPAIRED=1so refc treats the twin pair as a single logical peer, and its[TRUNK_IT_C]to refa is a normal (non-paired) trunk. - satellite on ref1 (
TWIN_SATELLITE_PARENT="ref1") — a satellite server is enabled on ref1 so tests 9 and 10 can verify that audio mirrored over the[TWIN]link is re-forwarded out to satellites attached to the partner.
Twin Port Mapping
| Reflector | Client (TCP+UDP) | Trunk (TCP) | Twin (TCP) | Satellite | HTTP |
|---|---|---|---|---|---|
| refa | 45300 | 45302 | — | — | 48080 |
| ref1 | 46300 | 46302 | 46304 | 46303 | 49080 |
| ref2 | 47300 | 47302 | 47304 | — | 50080 |
| refc | 48300 | 48302 | — | — | 51080 |
Internal port for [TWIN] is always 5304; satellite is 5303.
File Structure
| File | Purpose |
|---|---|
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, 52 test cases, interactive loop. |
test_alias.py |
Local-alias tests (9 cases): two-way/out/in direction semantics, rewrite-on-select, /status.local_aliases, unowned-alias rejection at load. Runs on the default mesh; reuses ClientPeer/get_status/wait_until from test_trunk.py. See Local Aliases below. |
test_mqtt_deltas.py |
Peer-client liveness MQTT delta tests (7 cases): per-client connect/disconnect/rx events published as peer/<peer_id>/client/<call>/<event>, 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_<id> 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 → regenerate routable → build → routable tests → teardown. |
configs/ |
Generated reflector config files (do not edit manually) |
docker-compose.test.yml |
Generated compose file (do not edit manually) |
topology_redis.py |
Topology for the Redis test harness (single reflector + Redis). |
generate_redis_configs.py |
Generates configs-redis/*.conf and docker-compose.redis.yml. |
test_routable.py |
Routable-prefix tests (2 cases): explicit multi-hop transit (forward + return) and * wildcard with blacklist veto. Run automatically as phase 3 of run_tests.sh on a dedicated compose stack; configs and docker-compose.routable.yml are generated by python3 generate_configs.py --topology routable (routable topology defined in topology.py under ROUTABLE_REFLECTORS). To run standalone: docker compose -f docker-compose.routable.yml up -d --build --wait then python3 test_routable.py. |
test_redis.py |
Redis-backed config-store tests (13 cases): users, trunk filters, live-state hashes, outage/resync, import idempotence, peer-node mirroring + sanitization, dynamic trunk add/remove. |
run_redis_tests.sh |
Redis test orchestrator with up/test/down/all subcommands. |
configs-redis/ |
Generated Redis-harness configs (do not edit manually) |
docker-compose.redis.yml |
Generated Redis compose file (do not edit manually) |
Test Harness Components
TrunkPeer
Simulates a trunk peer connection. Connects via TCP, performs HMAC handshake, and can send/receive all trunk protocol messages (TalkerStart, TalkerStop, Audio, Flush, Heartbeat).
SatellitePeer
Extends TrunkPeer with satellite-specific behavior: connects to the satellite port and sends a hello with role=SATELLITE. Authentication is two-way: the satellite proves identity to the parent, then the parent sends a hello reply back so the satellite can verify the parent and enable event forwarding.
ClientPeer
Simulates a V2 SvxLink client. Performs the full TCP authentication handshake (ProtoVer → AuthChallenge → AuthResponse → AuthOk → ServerInfo), opens a UDP socket for audio, and supports TG selection, TG monitoring, sending/receiving UDP audio frames, and background TCP message draining.
Test Cases
Trunk Protocol
| # | Test | What it verifies |
|---|---|---|
| 1 | Mesh connectivity | All trunk links between the 3 reflectors are connected (via /status) |
| 2 | Handshake success | Test peer connects, receives hello back with correct prefix and priority nonce |
| 3 | Bad secret rejected | Connection with wrong HMAC secret is dropped |
| 4 | Talker start/stop | TalkerStart appears in /status active_talkers, TalkerStop clears it |
| 5 | Audio relay | Full lifecycle: start → 5 audio frames → flush → stop, all accepted |
| 6 | Cluster TGs accepted | All cluster TGs are accepted regardless of prefix; verified NOT forwarded trunk-to-trunk |
| 7 | Heartbeat keepalive | Sending heartbeats keeps the connection alive after 3 seconds |
| 8 | Disconnect cleanup | Abrupt TCP close clears the talker from /status |
| 9 | No trunk-to-trunk audio | Audio from TRUNK_TEST is NOT forwarded to TRUNK_TEST_RX (loop prevention) |
End-to-End Audio
| # | Test | What it verifies |
|---|---|---|
| 10 | Audio to local client | Trunk audio on a cluster TG reaches a V2 client on the same reflector via UDP |
| 11 | Cross-reflector audio | V2 client on reflector-a talks on a TG owned by reflector-b; V2 client on reflector-b receives the audio via trunk forwarding |
Satellite Links
| # | Test | What it verifies |
|---|---|---|
| 12 | Satellite handshake | Satellite connects and appears as authenticated in /status |
| 13 | Satellite audio to parent | Audio sent by satellite reaches a V2 client on the parent reflector |
| 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 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[<id>].filter; key absent when unset, appears after send, clears after empty filter |
Bidirectional and Multi-Way Routing
| # | Test | What it verifies |
|---|---|---|
| 17 | Bidirectional trunk conversation | Client-A on reflector-a talks on a TG owned by reflector-b, Client-B on reflector-b receives it; Client-B replies, Client-A receives the return audio (peer interest tracking) |
| 32 | Three-way conversation across the mesh | One distinct V2 client on each of the three reflectors selects a TG owned by reflector-b (prefix-match winner). Every client speaks in turn and both other clients must receive UDP audio/flush. Exercises owner-relay: when a non-owner forwards audio to the owner, the owner re-broadcasts to every other trunk peer with interest — the single-hop fanout that makes trunks a true audio mesh rather than an owner-local delivery. The test uses a 2-pass round-robin (first pass primes m_peer_interested_tgs; second pass measures all 6 sender→listener pairs) and sends periodic TCP heartbeats so idle listener sockets do not hit HEARTBEAT_RX_CNT_RESET. |
MQTT Publishing
| # | Test | What it verifies |
|---|---|---|
| 18 | MQTT talker event | Talker start/stop on a trunk publishes to `/talker//(start |
| 26 | MQTT_NAME in topic |
Reflector with MQTT_NAME=mqname-c publishes node-list under <prefix>/c/mqname-c/nodes/local |
| 28 | MQTT client connect/disconnect | V2 client connect publishes client/<callsign>/connected (with tg, ip); disconnect publishes client/<callsign>/disconnected |
| 29 | MQTT full status | Periodic retained status message arrives and contains nodes and trunks keys |
| 30 | MQTT local nodes | Client connect triggers retained nodes/local message listing the client's callsign with timestamp |
| 31 | MQTT works in satellite mode | A satellite-mode reflector (reflector-sat, SATELLITE_OF=reflector-a) publishes client/<callsign>/connected and disconnected events under its own topic prefix |
Per-Trunk Filters and Mapping (jayReflector additions)
A third test peer TRUNK_TEST_FILTER (prefix 7, secret test_secret_filter)
is configured with PEER_ID=filter-peer, BLACKLIST_TGS=12345,
ALLOW_TGS=7*,1220, and TG_MAP=7000:1220 so these tests can verify
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 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 |
| 21b | Filter trims node roster | A peer node whose selected TG is blacklisted or outside ALLOW_TGS is dropped from /status.trunks[SECTION].nodes (same gate as audio/active talkers) |
| 21c | Filter trims monitoredTGs |
A node kept on a permitted selected TG has non-permitted entries scrubbed from its status-blob monitoredTGs array |
| 22 | TG_MAP remap |
TalkerStart on wire TG 7000 is remapped and tracked as local TG 1220 |
| 23 | PTY TRUNK STATUS |
Command is accepted; TRUNK_TEST_FILTER is loaded by the reflector |
| 24 | PTY TRUNK MUTE |
Audio from a muted callsign is dropped before reaching local clients |
| 25 | PTY TRUNK RELOAD |
After live CFG update of BLACKLIST_TGS, TRUNK RELOAD re-reads it and the formerly-allowed TG is now blocked |
Trunk Node-List Exchange
| # | Test | What it verifies |
|---|---|---|
| 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[<sat_id>].nodes |
| 34 | Sat-attached client on trunk peer | The same client appears on a far trunk peer's /status.trunks[<section>].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 |
Local Aliases
Phase 1 of run_tests.sh: test_alias.py on the default mesh. Reflector-a
carries LOCAL_ALIASES=8:1220008,90:1220090/out,91:1220091/in; reflector-b
(direct trunk peer, prefix 121) plays the "peer abroad" whose clients dial
the long numbers directly (b has no alias table of its own).
| # | Test | What it verifies |
|---|---|---|
| 01 | Two-way — local delivery unaffected | Both nodes select the short TG 8; plain same-reflector delivery still works, and /status.nodes[*].tg == 8 for both |
| 02 | Two-way — reaches peer | A-node keys short TG 8; a B-node that selected the long TG 1220008 (expressing interest) receives the audio — outbound aliasToRoute publish |
| 03 | Two-way — inbound folds to local | B-node keys the long TG 1220008 directly; an A-node monitoring short TG 8 receives it — inbound aliasToLocal delivery |
| 04 | /out — publishes, no inbound |
Alias 90:1220090/out: A's short TG 90 still reaches B, but B keying the long TG 1220090 is NOT delivered to an A-node monitoring short TG 90 |
| 05 | /in — folds inbound, no publish |
Alias 91:1220091/in: A's short TG 91 does NOT reach a B-node monitoring the long TG 1220091, but B keying the long TG 1220091 IS delivered to an A-node on short TG 91 |
| 06 | Rewrite-on-select | A client selecting the long TG 1220008 directly is folded onto the short TG — /status.nodes[<call>].tg == 8 |
| 07 | /status exposes aliases |
/status.local_aliases matches the configured table exactly, keyed by short TG with alias (long number) and direction |
| 08 | Reject unowned alias | A standalone reflector booted with LOCAL_ALIASES=8:1220008,7:9990007 (9990007 outside LOCAL_PREFIX=122) keeps the valid entry, rejects the invalid one (absent from /status.local_aliases, logged), and still starts |
| 09 | Multi-hop by number | Skipped on the default topology: the only extra hop (d, prefix 1219) nests under b's prefix (121), not under a's owned prefix (122) that hosts the alias table, so peer-interest can't propagate through b to d without extra ROUTABLE_PREFIXES plumbing out of scope for this topology change |
Routable Prefixes
Phase 3 of run_tests.sh: test_routable.py against a dedicated routable-prefix
chain topology (also runnable standalone — see the file table above).
| # | Test | What it verifies |
|---|---|---|
| R1 | Explicit transit forward + return | A client on a leaf reflector activates a TG owned by a far reflector two transit nodes away (three trunk links); audio traverses both transit hops (explicit ROUTABLE_PREFIXES on each intermediate trunk) and the return audio reaches the leaf via peer interest |
| R2 | * wildcard + blacklist veto |
A client on a *-configured leaf reaches a remote TG via its single uplink; a TG listed in BLACKLIST_TGS on the same link is dropped regardless of the wildcard, confirming blacklist-before-routable evaluation order |
Twin Protocol (HA-pair)
Phase 2 of run_tests.sh: test_twin.py against the twin topology. See docs/TWIN_PROTOCOL.md for the protocol.
| # | Test | What it verifies |
|---|---|---|
| 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/<call>/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
Run independently with run_redis_tests.sh. These exercise the Redis-backed config store against a single reflector (r1) plus a Redis container, generated from topology_redis.py.
cd tests
bash run_redis_tests.sh # full cycle: up → test → down
bash run_redis_tests.sh up # start stack and leave it running
bash run_redis_tests.sh test # run test_redis.py against running stack
bash run_redis_tests.sh down # tear down
Each test writes directly to Redis via redis-cli inside the container, publishes on the <key-prefix>:config.changed channel, and asserts either on reflector behavior (V2 auth accept/reject, trunk filter reload, trunk link add/remove) or on Redis state (live:client:<callsign> hashes).
| # | Test | What it verifies |
|---|---|---|
| 1 | User add + authenticate | HSET user:… + publish users lets a new V2 client authenticate within ~1 s |
| 2 | User disable rejects auth | Setting enabled=0 and republishing causes subsequent auth to fail |
| 3 | Blacklist change triggers reload | Adding/removing a trunk:<SECTION>:blacklist member logs Reloaded filters with the expected fragment |
| 4 | Allow change triggers reload | Adding an allow-list entry produces a matching Reloaded filters line |
| 5 | live:client appears on auth |
On V2 authentication, live:client:<callsign> hash is populated with connected_at, ip, tg, codecs |
| 6 | live:client disappears on disconnect |
After forceful TCP close the hash is removed within ~5 s |
| 6b | live:client rich status blob |
After the client sends MsgNodeInfo, live:client:<callsign>.status holds the full per-client JSON (qth, rx params, monitoredTGs) and updated_at |
| 6c | live:meta populated |
live:meta hash carries mode, version, local_prefix, listen_port, cluster_tgs, updated_at after a config.changed all republish |
| 6d | live:trunk carries status blob |
live:trunk:<section>.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 MsgPeerNodeList creates live:peer_node:<section>:<callsign> 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:<section>:* keys for that peer |
| 12 | Dynamic trunk add/remove | Writing a trunk:<SECTION>:peer hash + publish logs Added trunk link: …; deleting it logs Removed trunk link: … |
| 13 | Incomplete peer skipped | A peer hash missing secret/remote_prefix is ignored (no link created, reflector does not crash) |
Interactive Mode
After the automated tests pass, an interactive prompt lets you test any TG number:
TG number (q to quit): 12101
logs for TG 12101:
reflector-a: local talker start, local talker stop
reflector-b: trunk talker start, trunk talker stop
reflector-c: (no events)
✔ TG 12101 routed via trunk
The interactive mode connects a V2 client to reflector-a, sends audio on the given TG, then checks docker logs on each reflector for routing evidence.
Modifying the Topology
All topology is defined in topology.py. The file contains two topologies:
- Default (
REFLECTORS,CLUSTER_TGS,TEST_PEER, etc.) — the 3-reflector mesh used bytest_trunk.py. - Twin (
TWIN_REFLECTORS,TWIN_TRUNKS,TWIN_CLUSTER_TGS) — the 4-reflector twin topology used bytest_twin.py, includingtwin_ofandpairedfields.
To add a reflector or change prefixes:
- Edit the relevant constants in
topology.py - Run
python3 generate_configs.py(default) orpython3 generate_configs.py --topology twin - Run
bash run_tests.shto rebuild and test both suites
Do not edit files in configs/ or docker-compose.test.yml directly — they are overwritten by the generator.