publishing: MQTT works in satellite mode + Redis publishes per-client status blob
- Move MQTT init above the satellite early-return in Reflector::initialize so satellite-mode reflectors publish to MQTT (client connect/disconnect, talker events, full status, etc.) just like full reflectors. - Add reflector-sat (SATELLITE_OF=reflector-a) to the default test compose so satellite mode is exercised end-to-end. New test_31 verifies MQTT client-connect/disconnect events under the satellite's own topic prefix. - Add RedisStore::pushClientStatus and Reflector::publishClientStatus to write the per-client status JSON (qth, rx siglev/sql_open/enabled/active, monitoredTGs, selected TG, ...) to live:client:<callsign>.status. Hooked from publishRxUpdate, handleNodeInfo, setMonitoredTGs, and setTg. - New Redis test_live_client_status_blob sends a synthetic MsgNodeInfoV2 with qth+rx and asserts the parsed blob contains the expected fields. 31/31 trunk + 10/10 twin + 14/14 redis pass.
This commit is contained in:
1 parent
6b7a1f0306
commit
688a62ec5b
10 files changed
+299
-33
No files matched your search
@@ -126,6 +126,57 @@ def generate_reflector_conf(name: str) -> str:
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def generate_satellite_node_conf() -> str:
|
||||
"""Generate svxreflector.conf for a satellite-mode reflector that
|
||||
connects to the primary reflector as a satellite peer."""
|
||||
sat = T.SATELLITE_NODE
|
||||
parent = T.sat_node_parent()
|
||||
parent_svc = T.service_name(parent)
|
||||
parent_prefix = T.prefix_str(T.REFLECTORS[parent]["prefix"])
|
||||
|
||||
lines = [
|
||||
"[GLOBAL]",
|
||||
'TIMESTAMP_FORMAT="%c"',
|
||||
f"LISTEN_PORT={T.INTERNAL_CLIENT_PORT}",
|
||||
"TG_FOR_V1_CLIENTS=999",
|
||||
f"LOCAL_PREFIX={parent_prefix}",
|
||||
f"HTTP_SRV_PORT={T.INTERNAL_HTTP_PORT}",
|
||||
f"SATELLITE_OF={parent_svc}",
|
||||
f"SATELLITE_PORT={T.SATELLITE['listen_port']}",
|
||||
f"SATELLITE_SECRET={T.SATELLITE['secret']}",
|
||||
f"SATELLITE_ID={sat['id']}",
|
||||
"",
|
||||
"[SERVER_CERT]",
|
||||
f"COMMON_NAME={T.sat_node_service_name()}",
|
||||
"",
|
||||
"[USERS]",
|
||||
]
|
||||
groups_seen = set()
|
||||
for client in T.TEST_CLIENTS:
|
||||
lines.append(f"{client['callsign']}={client['group']}")
|
||||
groups_seen.add(client['group'])
|
||||
lines += [
|
||||
"",
|
||||
"[PASSWORDS]",
|
||||
]
|
||||
for client in T.TEST_CLIENTS:
|
||||
if client['group'] in groups_seen:
|
||||
lines.append(f"{client['group']}={client['password']}")
|
||||
groups_seen.discard(client['group'])
|
||||
lines += [
|
||||
"",
|
||||
"[MQTT]",
|
||||
f"HOST={T.MQTT['host']}",
|
||||
f"PORT={T.MQTT['port']}",
|
||||
f"USERNAME={T.MQTT['username']}",
|
||||
f"PASSWORD={T.MQTT['password']}",
|
||||
f"TOPIC_PREFIX=svxreflector/{sat['name']}",
|
||||
"STATUS_INTERVAL=1000",
|
||||
"",
|
||||
]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def generate_docker_compose() -> str:
|
||||
"""Generate docker-compose.test.yml content."""
|
||||
services = []
|
||||
@@ -174,6 +225,30 @@ def generate_docker_compose() -> str:
|
||||
networks:
|
||||
- trunk_mesh{depends_on_line}""")
|
||||
|
||||
# Satellite-mode reflector — joins the primary as a satellite. Used
|
||||
# to verify satellite-mode behavior (MQTT publishing, V2 client server).
|
||||
sat_svc = T.sat_node_service_name()
|
||||
sat_vol = f"pki-{T.SATELLITE_NODE['name']}"
|
||||
volumes.append(sat_vol)
|
||||
services.append(f""" {sat_svc}:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- ./configs/{sat_svc}.conf:/etc/svxlink/svxreflector.conf:ro
|
||||
- {sat_vol}:/var/lib/svxlink/pki
|
||||
ports:
|
||||
- "{T.sat_node_mapped_client_port()}:{T.INTERNAL_CLIENT_PORT}/tcp"
|
||||
- "{T.sat_node_mapped_client_port()}:{T.INTERNAL_CLIENT_PORT}/udp"
|
||||
- "{T.sat_node_mapped_http_port()}:{T.INTERNAL_HTTP_PORT}/tcp"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "bash -c '(echo > /dev/tcp/localhost/{T.INTERNAL_HTTP_PORT}) 2>/dev/null'"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 15
|
||||
networks:
|
||||
- trunk_mesh""")
|
||||
|
||||
# Mosquitto broker for MQTT testing
|
||||
services.append(""" mosquitto:
|
||||
image: eclipse-mosquitto:2
|
||||
@@ -496,6 +571,13 @@ def main():
|
||||
f.write(content)
|
||||
print(f" wrote {os.path.relpath(path, script_dir)}")
|
||||
|
||||
# Satellite-mode reflector config
|
||||
sat_path = os.path.join(configs_dir,
|
||||
f"{T.sat_node_service_name()}.conf")
|
||||
with open(sat_path, "w") as f:
|
||||
f.write(generate_satellite_node_conf())
|
||||
print(f" wrote {os.path.relpath(sat_path, script_dir)}")
|
||||
|
||||
# Generate docker-compose
|
||||
compose_path = os.path.join(script_dir, "docker-compose.test.yml")
|
||||
with open(compose_path, "w") as f:
|
||||
|
||||
Reference in new issue
Block a user