mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(gateway): fix discrepancies in gateway status
This commit is contained in:
parent
511ed4dacc
commit
8ab1aa2efc
9 changed files with 329 additions and 166 deletions
|
|
@ -799,35 +799,30 @@ class TestEdgeCases:
|
|||
assert default.skill_count == 0
|
||||
|
||||
def test_gateway_running_check_with_pid_file(self, profile_env):
|
||||
"""Verify _check_gateway_running reads pid file and probes os.kill."""
|
||||
"""Verify _check_gateway_running uses the shared gateway PID validator."""
|
||||
from hermes_cli.profiles import _check_gateway_running
|
||||
tmp_path = profile_env
|
||||
default_home = tmp_path / ".hermes"
|
||||
|
||||
# No pid file -> not running
|
||||
assert _check_gateway_running(default_home) is False
|
||||
|
||||
# Write a PID file with a JSON payload
|
||||
pid_file = default_home / "gateway.pid"
|
||||
pid_file.write_text(json.dumps({"pid": 99999}))
|
||||
|
||||
# os.kill(99999, 0) should raise ProcessLookupError -> not running
|
||||
assert _check_gateway_running(default_home) is False
|
||||
|
||||
# Mock os.kill to simulate a running process
|
||||
with patch("os.kill", return_value=None):
|
||||
with patch("gateway.status.get_running_pid", return_value=99999) as mock_get_running_pid:
|
||||
assert _check_gateway_running(default_home) is True
|
||||
mock_get_running_pid.assert_called_once_with(
|
||||
default_home / "gateway.pid",
|
||||
cleanup_stale=False,
|
||||
)
|
||||
|
||||
def test_gateway_running_check_plain_pid(self, profile_env):
|
||||
"""Pid file containing just a number (legacy format)."""
|
||||
"""Shared PID validator returning None means the profile is not running."""
|
||||
from hermes_cli.profiles import _check_gateway_running
|
||||
tmp_path = profile_env
|
||||
default_home = tmp_path / ".hermes"
|
||||
pid_file = default_home / "gateway.pid"
|
||||
pid_file.write_text("99999")
|
||||
|
||||
with patch("os.kill", return_value=None):
|
||||
assert _check_gateway_running(default_home) is True
|
||||
with patch("gateway.status.get_running_pid", return_value=None) as mock_get_running_pid:
|
||||
assert _check_gateway_running(default_home) is False
|
||||
mock_get_running_pid.assert_called_once_with(
|
||||
default_home / "gateway.pid",
|
||||
cleanup_stale=False,
|
||||
)
|
||||
|
||||
def test_profile_name_boundary_single_char(self):
|
||||
"""Single alphanumeric character is valid."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue