From 287cf947bd360af31a8d900c8d2c0baa28a1724a Mon Sep 17 00:00:00 2001 From: Eugeniusz Gilewski Date: Sun, 26 Jul 2026 22:57:05 +0200 Subject: [PATCH] test(gateway): isolate runtime PID identity fallback Stub the command-line probe in the unreadable-inspection fallback test so a coincidental live PID cannot make it depend on the host process table. Add a separate case that pins rejection of an unrelated live process. --- .../hermes_cli/test_gateway_runtime_health.py | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/hermes_cli/test_gateway_runtime_health.py b/tests/hermes_cli/test_gateway_runtime_health.py index aeab6bfa63a6e..627575ed9d96e 100644 --- a/tests/hermes_cli/test_gateway_runtime_health.py +++ b/tests/hermes_cli/test_gateway_runtime_health.py @@ -76,8 +76,28 @@ def test_runtime_status_running_pid_validates_live_gateway_record(monkeypatch): } monkeypatch.setattr(status_mod, "_pid_exists", lambda pid: pid == 12345) monkeypatch.setattr(status_mod, "_get_process_start_time", lambda pid: None) - monkeypatch.setattr(status_mod, "_looks_like_gateway_process", lambda pid: False) + monkeypatch.setattr(status_mod, "_read_process_cmdline", lambda pid: None) assert status_mod.get_runtime_status_running_pid(runtime) == 12345 +def test_runtime_status_running_pid_rejects_unrelated_live_process(monkeypatch): + from gateway import status as status_mod + + runtime = { + "pid": 12345, + "kind": "hermes-gateway", + "argv": ["/opt/hermes/hermes_cli/main.py", "gateway", "run", "--replace"], + "start_time": None, + "gateway_state": "running", + } + monkeypatch.setattr(status_mod, "_pid_exists", lambda pid: pid == 12345) + monkeypatch.setattr(status_mod, "_get_process_start_time", lambda pid: None) + monkeypatch.setattr( + status_mod, + "_read_process_cmdline", + lambda pid: "/usr/bin/python unrelated-worker.py", + ) + + assert status_mod.get_runtime_status_running_pid(runtime) is None +