mirror of
https://github.com/ruvnet/RuView
synced 2026-06-30 13:43:18 +00:00
feat(adr-115): P4 — broker integration tests + mosquitto CI workflow
Adds three integration tests (`v2/crates/wifi-densepose-sensing-server/ tests/mqtt_integration.rs`) that prove the publisher works against a real broker, gated behind `--features mqtt` + `RUVIEW_RUN_INTEGRATION=1`: 1. `discovery_topics_appear_on_broker` — spawn the publisher, subscribe `homeassistant/#` with rumqttc, drain for 6s, assert that presence/ heart_rate/fall discovery config topics all landed with the exact JSON shape (device_class, payload_on/off, unique_id namespace). 2. `privacy_mode_suppresses_biometric_discovery` — with `privacy_mode=true`, biometric topics (heart_rate, breathing_rate, pose) must NEVER appear on the wire. Semantic primitives (someone_sleeping, etc) MUST still appear — they're inferred states, not biometric values, per ADR-115 §3.12.3. 3. `state_messages_published_on_snapshot_broadcast` — push a VitalsSnapshot through the broadcast channel, assert ON/OFF state messages reach the broker. Plus `.github/workflows/mqtt-integration.yml` — spins up Mosquitto 2.0.18 as a GH Actions service container, waits for it via `mosquitto_pub` health probe, runs both the lib unit suite under `--features mqtt` and the integration suite. Dumps broker logs on failure for debugging. Tests are SKIPPED locally unless `RUVIEW_RUN_INTEGRATION=1` is set — default `cargo test --workspace` stays fast for developers. Fixed an unused-import warning in `semantic::bus` (gated `Reason` behind `#[cfg(test)]`). Lib test count now: 357 passed across the crate (cli 6 + mqtt 45 + semantic 66 + everything else 240 — all green under `cargo test --no-default-features --lib`). Refs #776. Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
name: ADR-115 MQTT integration tests
|
||||
|
||||
# Runs the Mosquitto-broker-backed integration tests for ADR-115's MQTT
|
||||
# publisher. These prove the publisher reaches a real broker, emits the
|
||||
# expected HA-discovery topic shape, and honours --privacy-mode at the
|
||||
# wire boundary (not just in unit-test logic).
|
||||
#
|
||||
# Default `cargo test --workspace` does not run these tests because they
|
||||
# require a broker and pull rumqttc into the build. This workflow opts
|
||||
# into both by setting --features mqtt and RUVIEW_RUN_INTEGRATION=1.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'v2/crates/wifi-densepose-sensing-server/src/mqtt/**'
|
||||
- 'v2/crates/wifi-densepose-sensing-server/tests/mqtt_integration.rs'
|
||||
- 'v2/crates/wifi-densepose-sensing-server/Cargo.toml'
|
||||
- '.github/workflows/mqtt-integration.yml'
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'v2/crates/wifi-densepose-sensing-server/src/mqtt/**'
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
mqtt-integration:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
|
||||
services:
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto:2.0.18
|
||||
ports:
|
||||
- 11883:1883
|
||||
# No auth — we test the wire shape, not auth. Production
|
||||
# deployments enable mTLS per ADR-115 §3.9.
|
||||
options: >-
|
||||
--health-cmd "mosquitto_pub -h localhost -p 1883 -t healthcheck -m ok -q 0 || exit 0"
|
||||
--health-interval 5s
|
||||
--health-timeout 3s
|
||||
--health-retries 10
|
||||
|
||||
env:
|
||||
RUVIEW_RUN_INTEGRATION: "1"
|
||||
RUVIEW_TEST_MQTT_PORT: "11883"
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_BACKTRACE: 1
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Wait for mosquitto to be reachable
|
||||
run: |
|
||||
sudo apt-get update -qq && sudo apt-get install -y mosquitto-clients
|
||||
for i in {1..20}; do
|
||||
if mosquitto_pub -h 127.0.0.1 -p 11883 -t healthcheck -m ok -q 0; then
|
||||
echo "mosquitto reachable on 11883"; exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
echo "mosquitto never became reachable" >&2; exit 1
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: stable
|
||||
|
||||
- name: Cache cargo registry + build
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
workspaces: v2 -> target
|
||||
|
||||
- name: Verify unit tests still pass under --features mqtt
|
||||
working-directory: v2
|
||||
run: >-
|
||||
cargo test -p wifi-densepose-sensing-server
|
||||
--features mqtt --no-default-features
|
||||
--lib mqtt:: semantic:: cli::tests
|
||||
--no-fail-fast
|
||||
|
||||
- name: Run integration tests against mosquitto
|
||||
working-directory: v2
|
||||
run: >-
|
||||
cargo test -p wifi-densepose-sensing-server
|
||||
--features mqtt --no-default-features
|
||||
--test mqtt_integration
|
||||
--no-fail-fast
|
||||
-- --test-threads=1 --nocapture
|
||||
|
||||
- name: Dump broker logs on failure
|
||||
if: failure()
|
||||
run: |
|
||||
docker ps -a
|
||||
docker logs $(docker ps -aqf "ancestor=eclipse-mosquitto:2.0.18") || true
|
||||
Reference in New Issue
Block a user