Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket ping test has transient failures on loaded systems #8873

Closed
bdraco opened this issue Aug 23, 2024 · 2 comments
Closed

Websocket ping test has transient failures on loaded systems #8873

bdraco opened this issue Aug 23, 2024 · 2 comments
Assignees
Labels

Comments

@bdraco
Copy link
Member

bdraco commented Aug 23, 2024

          ### :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 #8868 (comment)

@bdraco bdraco self-assigned this Aug 23, 2024
@bdraco
Copy link
Member Author

bdraco commented Aug 23, 2024

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

@bdraco
Copy link
Member Author

bdraco commented Oct 28, 2024

test refactored in #9566

@bdraco bdraco closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants