aio-libs / aiohttp

Asynchronous HTTP client/server framework for asyncio and Python
https://docs.aiohttp.org
Other
14.95k stars 1.99k forks source link

Websocket ping test has transient failures on loaded systems #8873

Open bdraco opened 2 weeks ago

bdraco commented 2 weeks ago
          ### :x: 1 Tests Failed:
Tests completed Failed Passed Skipped
3203 1 3202 64
View the top 1 failed tests by shortest run time > > ``` > tests.test_client_ws_functional test_close_websocket_while_ping_inflight[pyloop] > ``` > >
Stack Traces | 0.175s run time > > > > > ``` > > aiohttp_client = <function aiohttp_client.<locals>.go at 0x000002A0BA0851B0> > > > > #x1B[0m#x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92mtest_close_websocket_while_ping_inflight#x1B[39;49;00m(#x1B[90m#x1B[39;49;00m > > aiohttp_client: AiohttpClient,#x1B[90m#x1B[39;49;00m > > ) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m > > #x1B[90m #x1B[39;49;00m#x1B[33m"""Test closing the websocket while a ping is in-flight."""#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > ping_received = #x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > #x1B[90m#x1B[39;49;00m > > #x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92mhandler#x1B[39;49;00m(request: web.Request) -> NoReturn:#x1B[90m#x1B[39;49;00m > > #x1B[94mnonlocal#x1B[39;49;00m ping_received#x1B[90m#x1B[39;49;00m > > ws = web.WebSocketResponse(autoping=#x1B[94mFalse#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m > > #x1B[94mawait#x1B[39;49;00m ws.prepare(request)#x1B[90m#x1B[39;49;00m > > msg = #x1B[94mawait#x1B[39;49;00m ws.receive()#x1B[90m#x1B[39;49;00m > > #x1B[94massert#x1B[39;49;00m msg.type #x1B[95mis#x1B[39;49;00m aiohttp.WSMsgType.BINARY#x1B[90m#x1B[39;49;00m > > msg = #x1B[94mawait#x1B[39;49;00m ws.receive()#x1B[90m#x1B[39;49;00m > > ping_received = msg.type #x1B[95mis#x1B[39;49;00m aiohttp.WSMsgType.PING#x1B[90m#x1B[39;49;00m > > #x1B[94mawait#x1B[39;49;00m ws.receive()#x1B[90m#x1B[39;49;00m > > #x1B[94massert#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > #x1B[90m#x1B[39;49;00m > > app = web.Application()#x1B[90m#x1B[39;49;00m > > app.router.add_route(#x1B[33m"#x1B[39;49;00m#x1B[33mGET#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, handler)#x1B[90m#x1B[39;49;00m > > #x1B[90m#x1B[39;49;00m > > client = #x1B[94mawait#x1B[39;49;00m aiohttp_client(app)#x1B[90m#x1B[39;49;00m > > resp = #x1B[94mawait#x1B[39;49;00m client.ws_connect(#x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, heartbeat=#x1B[94m0.1#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m > > #x1B[94mawait#x1B[39;49;00m resp.send_bytes(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mask#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m > > #x1B[90m#x1B[39;49;00m > > cancelled = #x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > ping_stated = #x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > #x1B[90m#x1B[39;49;00m > > #x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92mdelayed_ping#x1B[39;49;00m() -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m > > #x1B[94mnonlocal#x1B[39;49;00m cancelled, ping_stated#x1B[90m#x1B[39;49;00m > > ping_stated = #x1B[94mTrue#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > #x1B[94mtry#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m > > #x1B[94mawait#x1B[39;49;00m asyncio.sleep(#x1B[94m1#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m > > #x1B[94mexcept#x1B[39;49;00m asyncio.CancelledError:#x1B[90m#x1B[39;49;00m > > cancelled = #x1B[94mTrue#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > #x1B[94mraise#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > #x1B[90m#x1B[39;49;00m > > #x1B[94mwith#x1B[39;49;00m mock.patch.object(resp._writer, #x1B[33m"#x1B[39;49;00m#x1B[33mping#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, delayed_ping):#x1B[90m#x1B[39;49;00m > > #x1B[94mawait#x1B[39;49;00m asyncio.sleep(#x1B[94m0.1#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m > > #x1B[90m#x1B[39;49;00m > > #x1B[94mawait#x1B[39;49;00m resp.close()#x1B[90m#x1B[39;49;00m > > #x1B[94mawait#x1B[39;49;00m asyncio.sleep(#x1B[94m0#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m > > > #x1B[94massert#x1B[39;49;00m ping_stated #x1B[95mis#x1B[39;49;00m #x1B[94mTrue#x1B[39;49;00m#x1B[90m#x1B[39;49;00m > > #x1B[1m#x1B[31mE assert False is True#x1B[0m > > > > aiohttp_client = <function aiohttp_client.<locals>.go at 0x000002A0BA0851B0> > > app = <Application 0x2a0b8b6c130> > > cancelled = False > > client = <aiohttp.test_utils.TestClient object at 0x000002A0B8B6F220> > > delayed_ping = <function test_close_websocket_while_ping_inflight.<locals>.delayed_ping at 0x000002A0BA086170> > > handler = <function test_close_websocket_while_ping_inflight.<locals>.handler at 0x000002A0BA085E10> > > ping_received = False > > ping_stated = False > > resp = <aiohttp.client_ws.ClientWebSocketResponse object at 0x000002A0B8B6FB50> > > > > #x1B[1m#x1B[31mtests\test_client_ws_functional.py#x1B[0m:802: AssertionError > > ``` > >

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Originally posted by @codecov[bot] in https://github.com/aio-libs/aiohttp/issues/8868#issuecomment-2307248725

bdraco commented 2 weeks ago

The code seems fine. The test needs a bit more time to run