test(issue-26): no test depends on a third-party MQTT broker
- tests/_local_mqtt.py: in-process MQTT 3.1.1 broker on 127.0.0.1 (what the repo uses: protocol level 4, clean session, QoS 0/1, retained). - conftest: one session broker named by MQTT_BROKER/MQTT_PORT/MQTT_TLS; other redirecting/auth MQTT_* dropped and restored afterwards. - Harnesses of the 22 broker-dependent tests (#18 acceptance1/2/3/5, #6 t1_1/2/7/8/14/15/16/20, #19 MQTT loop x2, #33 b3/r3/b7, #30 s9/s10/r2) use it; the "broker unreachable" skips are gone (a local broker that does not deliver is a failure). acceptance1/5 and #19 also assert on the subscriber, runner and audit logs the real producers write. - tests/test_local_mqtt.py: conformance with the real clients and the real publish_event -> job_subscriber path (C0), an AST guard against public broker literals and MQTT_* deleted without a replacement (C2), and the session's broker config (C3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
80dc2eb45e
commit
2826e709ae
8 files changed
+656
-49
No files matched your search
@@ -28,6 +28,8 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from _local_mqtt import local_broker_env
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures" / "issue_5" / "phase1"
|
||||
DELEGATION_MODES = ("0", "1")
|
||||
|
||||
@@ -415,11 +417,12 @@ def test_sub_stop_trap_exits_143_before_the_first_background_child():
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _start_connected(mam_sandbox, log):
|
||||
proc = _start_subscriber(mam_sandbox, log, {})
|
||||
if not _wait_for(log, r"MQTT Monitor: subscribed to ", 45):
|
||||
# Issue #26: the session's in-process broker is always up - not reaching it fails.
|
||||
proc = _start_subscriber(mam_sandbox, log, local_broker_env())
|
||||
if not _wait_for(log, r"MQTT Monitor: subscribed to mam/[0-9a-f]{12}/jobs/\+/events", 45):
|
||||
proc.kill()
|
||||
proc.wait(timeout=10)
|
||||
pytest.skip("broker unreachable from this host: " + log.read_text()[-300:])
|
||||
pytest.fail("the monitor daemon never subscribed on the local broker: " + log.read_text()[-300:])
|
||||
return proc
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user