fix(tests): align systemd unit + service tests with current production shape (partial close #9) #15
Merged
claude-ceo-assistant
merged 1 commits from 2026-05-08 21:12:01 +00:00
fix/systemd-tests-drift-9 into main
1 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9dc9a6998f |
fix(test_gateway_service,test_gateway_wsl): align systemd tests with current production shape (partial close hermes-agent#9)
Some checks failed
Nix / nix (macos-latest) (pull_request) Waiting to run
Contributor Attribution Check / check-attribution (pull_request) Failing after 1m36s
Supply Chain Audit / Scan PR for critical supply chain risks (pull_request) Successful in 1m37s
Tests / e2e (pull_request) Successful in 1m59s
Tests / test (pull_request) Failing after 18m17s
Nix / nix (ubuntu-latest) (pull_request) Failing after 22m16s
Sub-shape A (TimeoutStopSec literal drift): - generate_systemd_unit() formula: max(60, drain_timeout) + 30 - DEFAULT_GATEWAY_RESTART_DRAIN_TIMEOUT bumped 60→180 in config.py, so emitted TimeoutStopSec went 90→210; tests pinned the literal 90. - Replace literal with TestGeneratedSystemdUnits._expected_timeout_stop_sec() helper that mirrors the production formula via _get_restart_drain_timeout(), so future config-default bumps don't silently regress the test. Sub-shape B (production preflight not stubbed): - systemd_start() / systemd_restart() now call _preflight_user_systemd() before the systemctl call sequence (PR #14531: "preflight user D-Bus before systemctl --user start"). The preflight invokes loginctl enable-linger and waits for the D-Bus socket — neither of which the unit tests' fake subprocess runner answers. - Unit-tests under TestSystemdServiceRefresh and TestGatewaySystemServiceRouting assert the systemctl call sequence, not the preflight; preflight has dedicated coverage in TestUserSystemdPrivateSocketPreflight. Stub _preflight_user_systemd as a no-op in the four affected tests. Sub-shape B (supports_systemd_services container branch): - supports_systemd_services() now branches on is_container() to decide whether to probe `systemctl is-system-running`. Tests that assert the native-Linux True path didn't stub is_container, so a containerized CI runner inherited a real probe of the runner image's systemd: - test_supports_systemd_services_returns_true_when_systemctl_present - TestSupportsSystemdServicesWSL.test_native_linux - Stub is_container() False in both, plus shutil.which() in the WSL test so it also passes on macOS dev boxes (was implicitly Linux-only via systemctl-on-PATH). Tests fixed: test_systemd_start_refreshes_outdated_unit test_systemd_restart_refreshes_outdated_unit test_user_unit_avoids_recursive_execstop_and_uses_extended_stop_timeout test_system_unit_avoids_recursive_execstop_and_uses_extended_stop_timeout test_supports_systemd_services_returns_true_when_systemctl_present test_systemd_restart_self_requests_graceful_restart_and_waits test_systemd_restart_recovers_failed_planned_restart TestSupportsSystemdServicesWSL.test_native_linux Verified locally on darwin py3.13: all 8 target tests pass; one unrelated macOS-only failure (test_wsl_with_systemd) remains because its body relies on the host having systemctl on PATH — not in this PR's scope (not in the issue's failing-list). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |