Skip to content

The agent that grows with you

fix(tests): live-owner host-record fixtures hold the host lock, as the gateway does

Teknium342eed44fdd3
diff --git a/tests/hermes_cli/test_gateway_migrate_converged_host.py b/tests/hermes_cli/test_gateway_migrate_converged_host.py
index 064482f90f3..ae469ae0da4 100644
--- a/tests/hermes_cli/test_gateway_migrate_converged_host.py
+++ b/tests/hermes_cli/test_gateway_migrate_converged_host.py
@@ -61,6 +61,8 @@ def converged_host(tmp_path, monkeypatch):
# The WIRE only: the owner's control socket answer. Everything that reads it is real.
monkeypatch.setattr("gateway.control_socket.identify_gateway",
lambda home: {"pid": pid, "hermes_home": str(root), "served_profiles": served})
+ # A live owner holds the host lock for its lifetime (run.py claims before it publishes).
+ assert hr.claim_host_lock(hr.ROLE_GATEWAY)[0] is hr.HostLockOutcome.ACQUIRED
hr.publish_record(hr.ROLE_GATEWAY, profiles=tuple(served), home=str(root))
host_attach.invalidate_host_gateway_cache()
@@ -72,6 +74,7 @@ def converged_host(tmp_path, monkeypatch):
monkeypatch.setattr(gm, "_host_supports_migration", lambda: None)
yield type("Fixture", (), {"root": root, "signals": signals, "pid": pid, "served": served})
hr.clear_record(hr.ROLE_GATEWAY)
+ hr.release_host_lock(hr.ROLE_GATEWAY)
def test_the_host_gateway_pid_is_reported_for_every_secondary(converged_host):
diff --git a/tests/hermes_cli/test_gateway_restart_warm_probe_cache.py b/tests/hermes_cli/test_gateway_restart_warm_probe_cache.py
index 2eaae7c4205..d30ddcdf82d 100644
--- a/tests/hermes_cli/test_gateway_restart_warm_probe_cache.py
+++ b/tests/hermes_cli/test_gateway_restart_warm_probe_cache.py
@@ -50,6 +50,8 @@ def manual_host_gateway(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_GATEWAY_LOCK_DIR", str(tmp_path / "locks"))
home = get_hermes_home()
child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(60)"])
+ # A live owner holds the host lock for its lifetime (run.py claims before it publishes).
+ assert hr.claim_host_lock(hr.ROLE_GATEWAY)[0] is hr.HostLockOutcome.ACQUIRED
_write_record(child.pid, home)
identity = {"pid": child.pid, "hermes_home": str(home), "supervisor": "none",
"launch_supervisor": "manual", "served_profiles": [{"home": str(home)}]}
@@ -57,6 +59,7 @@ def manual_host_gateway(tmp_path, monkeypatch):
try:
yield child
finally:
+ hr.release_host_lock(hr.ROLE_GATEWAY)
if child.poll() is None:
child.terminate()
child.wait(timeout=10)