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
@@ -488,12 +488,7 @@ def test_scoped_env_drops_the_pane_inherited_workspace_for_name_lookups_only():
|
||||
import test_issue18_liveness_contract as t18 # noqa: E402
|
||||
|
||||
|
||||
LIVE_BROKER = ("MQTT_BROKER", "MQTT_PORT", "MQTT_TLS", "MQTT_USERNAME", "MQTT_PASSWORD")
|
||||
|
||||
|
||||
def _live_broker() -> dict:
|
||||
"""This environment's broker (the #18 harness defaults to a public one)."""
|
||||
return {k: os.environ[k] for k in LIVE_BROKER if k in os.environ}
|
||||
from _local_mqtt import local_broker_env # noqa: E402 (Issue #26: the session's in-process broker)
|
||||
|
||||
|
||||
def _watchers(jid: str) -> list:
|
||||
@@ -507,7 +502,7 @@ def test_s9_the_wrapper_runs_the_watcher_for_the_jobs_life(tmp_path, mock_herdr,
|
||||
reg.mkdir()
|
||||
t18._headless_agent(Path(mock_herdr), "headless-codex")
|
||||
proc, env = t18._submit(tmp_path, reg, "herdr:headless-codex", "codex", ["--ack-timeout", "40"],
|
||||
env_extra={"MAM_STALL_WATCH": switch, **_live_broker()}, timeout_s=60)
|
||||
env_extra={"MAM_STALL_WATCH": switch, **local_broker_env()}, timeout_s=60)
|
||||
jid = t18._wait_job_id(reg)
|
||||
try:
|
||||
time.sleep(1)
|
||||
@@ -533,7 +528,7 @@ def test_s10_remote_and_human_jobs_are_not_watched(tmp_path, agent, session, why
|
||||
reg = tmp_path / "jobs"
|
||||
reg.mkdir()
|
||||
proc, env = t18._submit(tmp_path, reg, session, agent, ["--ack-timeout", "40"], timeout_s=60,
|
||||
env_extra={"MAM_DISPATCH_SECRET": "s10-secret", **_live_broker()})
|
||||
env_extra={"MAM_DISPATCH_SECRET": "s10-secret", **local_broker_env()})
|
||||
jid = t18._wait_job_id(reg)
|
||||
try:
|
||||
time.sleep(1)
|
||||
@@ -620,7 +615,7 @@ def test_r2_the_loop_relays_a_blocked_notice_while_the_job_is_open(mam_sandbox,
|
||||
"SKS_IDLE_TIMEOUT_MS": "500", "SKS_EMPTY_GIVEUP": "1",
|
||||
"MAM_ACK_TIMEOUT_S": "40", "MAM_JOBS_DIR": str(reg),
|
||||
"PYTHONPATH": str(SKILLS), "PYTHONUNBUFFERED": "1"})
|
||||
env.update(_live_broker())
|
||||
env.update(local_broker_env())
|
||||
script = '''from lib_py.loop.runner import LoopRunner
|
||||
r = LoopRunner(["--creator", "headless-codex", "--task", "review check", "--job-timeout", "60"])
|
||||
r.parse_args()
|
||||
|
||||
Reference in new issue
Block a user