test(gateway): cover slow health clients

This commit is contained in:
Xubin Ren
2026-07-13 15:16:51 +08:00
parent 3824206ab2
commit a65a6f334c
3 changed files with 16 additions and 2 deletions
+11
View File
@@ -2889,6 +2889,7 @@ def test_gateway_health_endpoint_binds_and_serves_expected_responses(
assert captured["port"] == 18791
assert f"Health endpoint: {display_url}" in result.stdout
assert ("unauthenticated health endpoint" in result.stdout) is warns_about_public_bind
assert ("may be reachable from other devices" in result.stdout) is warns_about_public_bind
assert ("listening on 0.0.0.0" in result.stdout) is warns_about_public_bind
health_handler = captured["handler"]
@@ -2954,6 +2955,16 @@ def test_gateway_health_endpoint_binds_and_serves_expected_responses(
asyncio.run(_exercise_connection_limit())
class _NeverRespondingReader:
async def read(self, _size: int) -> bytes:
await asyncio.Event().wait()
monkeypatch.setattr(cli_commands, "_GATEWAY_HEALTH_READ_TIMEOUT_SECONDS", 0.01)
timed_out_writer = _FakeWriter()
asyncio.run(health_handler(_NeverRespondingReader(), timed_out_writer))
assert timed_out_writer.closed is True
assert timed_out_writer.output == b""
def test_gateway_shutdown_lets_agent_task_own_mcp_cleanup(
monkeypatch,