Four origin/main merges brought back `linux_only` / `macos_only` / `windows_only` marks in 41 test files, along with the pre-platforms() versions of scripts/ci/list_os_marked_tests.py and check_os_marker_fakes.py. Because the legacy names are no longer registered, pytest treated them as unknown marks — a warning — so every Windows- or macOS-only test RAN on Linux (test_local_runtime_recovery.py tripped the live-system kill guard). Rewrite the marks, restore the platforms()-aware CI scripts (keeping main's os.walk fix for vanishing __pycache__ dirs), drop the stale _BASELINE entries, and make the conftest reject the retired marks outright so the next merge cannot resurrect them silently.
53 lines
2.4 KiB
Python
53 lines
2.4 KiB
Python
"""``hermes gateway restart`` without an installed service unit must actually restart.
|
|
|
|
Linger is a systemd-unit concern. With no unit installed the detached ``run_gateway`` IS the
|
|
restart, yet the linger check ran unconditionally and bailed with exit 0 on any Linux login
|
|
session whose linger is off — the Desktop/dashboard "Restart gateway" action then reported
|
|
success while nothing restarted and the saved credentials never loaded.
|
|
"""
|
|
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.platforms("linux")
|
|
def test_restart_without_service_unit_runs_gateway_even_without_linger(monkeypatch):
|
|
from hermes_cli import gateway as gw
|
|
|
|
monkeypatch.setattr(gw, "_refuse_from_inside_gateway", lambda *a, **k: None)
|
|
monkeypatch.setattr(gw, "_dispatch_via_service_manager_if_s6", lambda *a, **k: False)
|
|
monkeypatch.setattr(gw, "_installed_service_kind_for", lambda windows: None)
|
|
monkeypatch.setattr(gw, "supports_systemd_services", lambda: True)
|
|
monkeypatch.setattr(gw, "get_systemd_linger_status", lambda *a, **k: (False, "Linger=no"))
|
|
monkeypatch.setattr(gw, "stop_profile_gateway", lambda: True)
|
|
monkeypatch.setattr(gw, "_wait_for_gateway_exit", lambda **k: None)
|
|
started = []
|
|
monkeypatch.setattr(gw, "run_gateway", lambda **k: started.append(k))
|
|
|
|
gw._cmd_restart(SimpleNamespace(system=False, all=False))
|
|
|
|
assert started, "no unit installed: restart must fall through to run_gateway, linger or not"
|
|
|
|
|
|
@pytest.mark.platforms("linux")
|
|
def test_restart_with_systemd_unit_still_reports_missing_linger(monkeypatch):
|
|
from hermes_cli import gateway as gw
|
|
|
|
monkeypatch.setattr(gw, "_refuse_from_inside_gateway", lambda *a, **k: None)
|
|
monkeypatch.setattr(gw, "_dispatch_via_service_manager_if_s6", lambda *a, **k: False)
|
|
monkeypatch.setattr(gw, "_installed_service_kind_for", lambda windows: "systemd")
|
|
|
|
def _failing_service_call(*a, **k):
|
|
import subprocess
|
|
raise subprocess.CalledProcessError(1, ["systemctl"])
|
|
|
|
monkeypatch.setattr(gw, "_service_call", _failing_service_call)
|
|
monkeypatch.setattr(gw, "supports_systemd_services", lambda: True)
|
|
monkeypatch.setattr(gw, "get_systemd_linger_status", lambda *a, **k: (False, "Linger=no"))
|
|
started = []
|
|
monkeypatch.setattr(gw, "run_gateway", lambda **k: started.append(k))
|
|
|
|
gw._cmd_restart(SimpleNamespace(system=False, all=False))
|
|
|
|
assert not started, "a broken unit must surface the linger hint, not double-start a detached gateway"
|