Skip to content

The agent that grows with you

test(update): fold the #97332 plan-kind cases into one invariant test

Teknium41e6b60249f8
diff --git a/tests/hermes_cli/test_update_fleet_check_fail_closed.py b/tests/hermes_cli/test_update_fleet_check_fail_closed.py
index 862746f9224..c4aeffd1a7b 100644
--- a/tests/hermes_cli/test_update_fleet_check_fail_closed.py
+++ b/tests/hermes_cli/test_update_fleet_check_fail_closed.py
@@ -52,56 +52,14 @@ class TestEmptySnapshotFailClosed:
is True
)
- def test_dashboard_only_plan_does_not_expect_rows(self):
- # #97332: the plan inventory also carries kind="dashboard" records
- # (#95576), but collect_fleet_versions() reports gateway identities
- # only. A dashboard-only plan (gateway never started) cannot ground
- # a rows-expected verdict — counting it made a successful update
- # print the incomplete-verification warning and exit 1.
- assert (
- _fleet_probe_expected_runtimes(
- _plan([RuntimeRecord(kind="dashboard", profile="default")]),
- [],
- None,
- [],
- set(),
- )
- is False
- )
-
- def test_serve_only_plan_does_not_expect_rows(self):
- # Same row-incapable reasoning as the dashboard record above: a
- # manually launched `hermes serve` backend never publishes the
- # gateway_state.json row the fleet probe would need.
- assert (
- _fleet_probe_expected_runtimes(
- _plan([RuntimeRecord(kind="serve", profile="default")]),
- [],
- None,
- [],
- set(),
- )
- is False
- )
-
- def test_mixed_plan_keys_on_gateway_record(self):
- # A dashboard running alongside a real gateway still expects rows:
- # the gateway record carries the expectation.
- assert (
- _fleet_probe_expected_runtimes(
- _plan(
- [
- RuntimeRecord(kind="dashboard", profile="default"),
- RuntimeRecord(kind="gateway", profile="work"),
- ]
- ),
- [],
- None,
- [],
- set(),
- )
- is True
- )
+ def test_plan_expectation_keys_on_gateway_kind_only(self):
+ # #97332: serve/dashboard plan records have no gateway_state.json row, so a
+ # dashboard-only or serve-only plan must not demand rows (that made a successful
+ # update exit 1); one gateway record alongside them still carries the expectation.
+ non_gateway = [RuntimeRecord(kind="dashboard", profile="default"), RuntimeRecord(kind="serve", profile="default")]
+ assert _fleet_probe_expected_runtimes(_plan(non_gateway), [], None, [], set()) is False
+ mixed = non_gateway + [RuntimeRecord(kind="gateway", profile="work")]
+ assert _fleet_probe_expected_runtimes(_plan(mixed), [], None, [], set()) is True
def test_windows_resume_token_alone_is_not_expected(self):
# (c) The Windows pause/resume token is EXCLUDED from the expectation
@@ -184,14 +142,22 @@ class TestCallSiteWiring:
def _impl_source(self):
from hermes_cli import update_cmd
- return inspect.getsource(update_cmd._cmd_update_impl)
+ # The fleet-version probe lives in the post-restart verifier that
+ # _cmd_update_impl calls; guard the wiring there.
+ return inspect.getsource(update_cmd._verify_fleet_after_update)
def test_settle_sleep_gated_on_expected_runtimes(self):
src = self._impl_source()
assert "_fleet_rows_expected = _m()._fleet_probe_expected_runtimes(" in src
# The 2.0s settle window must key on the cross-platform signal, so a
- # resumed Windows gateway gets its settle window too (#93406).
- assert "if _fleet_rows_expected:\n" in src
+ # resumed Windows gateway gets its settle window too (#93406). The
+ # settle loop lives in _collect_fleet_snapshot, gated on that signal.
+ assert "_fleet_snapshot = _collect_fleet_snapshot(restart, _fleet_rows_expected)" in src
+ from hermes_cli import update_cmd_fleet
+
+ snap_src = inspect.getsource(update_cmd_fleet._collect_fleet_snapshot)
+ assert "if not rows_expected:\n" in snap_src
+ assert "_time.sleep(2.0)" in snap_src
assert "if restarted_services or killed_pids:\n _time.sleep" not in src
def test_zero_row_guard_gated_on_expected_runtimes(self):
@@ -203,6 +169,7 @@ class TestCallSiteWiring:
)
+
def test_unmapped_stops_are_not_expected_rows():
# A gateway stopped WITHOUT a successor is listed under "Restart manually" and never
# publishes a row; counting it made the probe demand rows that cannot exist and the