Skip to content

The agent that grows with you

test(dashboard): pin the cron-fire endpoint resolution off the event loop

kshitijk4poor80570d7420ff
diff --git a/tests/hermes_cli/test_cron_fire_dashboard.py b/tests/hermes_cli/test_cron_fire_dashboard.py
index 1895a31ddcc..97bb4f2edca 100644
--- a/tests/hermes_cli/test_cron_fire_dashboard.py
+++ b/tests/hermes_cli/test_cron_fire_dashboard.py
@@ -209,6 +209,33 @@ def test_fire_endpoint_default_port(tmp_path, monkeypatch):
url = _web_server_cron._gateway_fire_endpoint("default", tmp_path)
assert url == "http://127.0.0.1:8642/api/cron/fire"
+ # Resolution reads config/.env (and multiplex state) — it must run off the dashboard loop.
+ import asyncio
+ import threading
+ import time
+
+ released = threading.Event()
+
+ def _blocking_endpoint(_profile, _home):
+ released.wait(3)
+ return "http://127.0.0.1:9/api/cron/fire" # discard port: refused, forward returns None
+
+ monkeypatch.setattr(_web_server_cron, "_gateway_fire_endpoint", _blocking_endpoint)
+ monkeypatch.setattr(_web_server_cron, "_cron_profile_home", lambda p: ("default", tmp_path))
+
+ async def _heartbeat_while_resolving():
+ forward = asyncio.ensure_future(
+ _web_server_cron._forward_cron_fire_to_gateway("default", "j1", "Bearer x"))
+ start = time.monotonic()
+ try:
+ await asyncio.sleep(0.05)
+ assert time.monotonic() - start < 1.0 and not forward.done()
+ finally:
+ released.set()
+ return await forward
+
+ assert asyncio.run(_heartbeat_while_resolving()) is None
+
def test_fire_endpoint_config_yaml_port_wins(tmp_path, monkeypatch):
"""The profile config.yaml port (read via the CANONICAL load_config, per