From d0caab9908e686767e60fa2e8460ec8357052d60 Mon Sep 17 00:00:00 2001 From: "congvc-bot[bot]" <3634010+congvc-bot[bot]@users.noreply.github.com> Date: Fri, 23 Oct 2026 19:42:05 +0700 Subject: [PATCH] fix(ci): stop fixed startup and read budgets failing wire-server tests on a busy host (CHE-2010) --- .../unit/admin_console/test_host_agent_api.py | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tests/unit/admin_console/test_host_agent_api.py b/tests/unit/admin_console/test_host_agent_api.py index ff48d3084..d99aee13d 100644 --- a/tests/unit/admin_console/test_host_agent_api.py +++ b/tests/unit/admin_console/test_host_agent_api.py @@ -38,6 +38,8 @@ from artemis.runtime.host_protocol import CONTRACT HOST = {"Host": "localhost"} +# Only stops a stalled wire test from hanging; a tight deadline on loopback I/O measures how busy the host is (CHE-2010). +STALL_BOUND = 60 def test_agent_unenroll_revokes_only_authenticated_identity(admin): @@ -259,12 +261,20 @@ async def startup(self, sockets=None): server = ReadyServer(config) task = asyncio.create_task(server.serve(sockets=[listener])) try: - await asyncio.wait_for(ready.wait(), 5) + ready_wait = asyncio.ensure_future(ready.wait()) + await asyncio.wait( + {ready_wait, task}, timeout=STALL_BOUND, return_when=asyncio.FIRST_COMPLETED + ) + ready_wait.cancel() + if not ready.is_set(): + if task.done(): + await task # surface the server's own startup error + raise AssertionError("wire server never became ready") yield f"localhost:{port}", tunnels, clock, outcomes, lost finally: server.should_exit = True try: - await asyncio.wait_for(task, 5) + await asyncio.wait_for(task, STALL_BOUND) finally: await tunnels.close() listener.close() @@ -286,7 +296,7 @@ async def test_real_host_socket_close_enters_grace_and_expires_once(admin, wire_ await ws.close() else: ws.transport.abort() - await asyncio.wait_for(lost.wait(), 1) + await asyncio.wait_for(lost.wait(), STALL_BOUND) assert tunnels.reconnecting(host_id) == 130 assert outcomes == [] clock["now"] = 130 @@ -325,14 +335,14 @@ async def test_agent_rejects_oversize_host_message_with_bridge_transport_cap( assert connected["type"] == "connected", connected tunnels.bind_run(host_id, "run") await ws.send(payload) - assert json.loads(await asyncio.wait_for(ws.recv(), 2)) == { + assert json.loads(await asyncio.wait_for(ws.recv(), STALL_BOUND)) == { "type": "error", "code": "bad_frame", } with pytest.raises(ConnectionClosedError) as closed: - await asyncio.wait_for(ws.recv(), 2) + await asyncio.wait_for(ws.recv(), STALL_BOUND) assert closed.value.rcvd.code == 4400 - await asyncio.wait_for(lost.wait(), 1) + await asyncio.wait_for(lost.wait(), STALL_BOUND) assert decode.call_count == (1 if isinstance(payload, bytes) else 2) assert frame_decode.call_count == (1 if isinstance(payload, bytes) else 0) @@ -363,20 +373,24 @@ async def fake_adb(*arguments): max_size=MAX_ADB_PACKET_BYTES, compression=None, ) as ws: - leased = json.loads(await asyncio.wait_for(ws.recv(), 2)) + leased = json.loads(await asyncio.wait_for(ws.recv(), STALL_BOUND)) assert leased["type"] == "session_leased" - assert json.loads(await asyncio.wait_for(ws.recv(), 2))["type"] == "device_attached" + assert ( + json.loads(await asyncio.wait_for(ws.recv(), STALL_BOUND))["type"] == "device_attached" + ) peer_reader, peer_writer = await asyncio.open_connection( leased["listener"]["host"], leased["listener"]["port"] ) try: await ws.send(packet) - assert await asyncio.wait_for(peer_reader.readexactly(len(packet)), 2) == packet + assert ( + await asyncio.wait_for(peer_reader.readexactly(len(packet)), STALL_BOUND) == packet + ) peer_writer.write(packet) await peer_writer.drain() - assert await asyncio.wait_for(ws.recv(), 2) == packet + assert await asyncio.wait_for(ws.recv(), STALL_BOUND) == packet await ws.send("close") - await asyncio.wait_for(ws.wait_closed(), 2) + await asyncio.wait_for(ws.wait_closed(), STALL_BOUND) finally: await bridge.revoke(leased["session_id"]) peer_writer.close() @@ -396,9 +410,9 @@ async def test_uvicorn_bounds_messages_at_the_bridge_limit(admin, wire_server): tunnels.bind_run(host_id, "run") await ws.send(bytes(MAX_ADB_PACKET_BYTES + 1)) with pytest.raises(ConnectionClosedError) as closed: - await asyncio.wait_for(ws.recv(), 2) + await asyncio.wait_for(ws.recv(), STALL_BOUND) assert closed.value.rcvd.code == 1009 - await asyncio.wait_for(lost.wait(), 1) + await asyncio.wait_for(lost.wait(), STALL_BOUND) # -- flag ---------------------------------------------------------------