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

5.10.0: pytest is failing #1270

Open
kloczek opened this issue Nov 5, 2023 · 4 comments
Open

5.10.0: pytest is failing #1270

kloczek opened this issue Nov 5, 2023 · 4 comments

Comments

@kloczek
Copy link

kloczek commented Nov 5, 2023

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix> using 'installer` module
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-socketio-5.10.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-socketio-5.10.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/python-socketio-5.10.0
collected 570 items

tests/async/test_admin.py FF.....F..                                     [  1%]
tests/async/test_client.py ............................................. [  9%]
..........................                                               [ 14%]
tests/async/test_manager.py ..............................               [ 19%]
tests/async/test_namespace.py .....................                      [ 23%]
tests/async/test_pubsub_manager.py ..................................    [ 29%]
tests/async/test_server.py ............................................. [ 37%]
............................                                             [ 41%]
tests/async/test_simple_client.py ................                       [ 44%]
tests/common/test_admin.py FF....F..                                     [ 46%]
tests/common/test_client.py ............................................ [ 54%]
........................................                                 [ 61%]
tests/common/test_manager.py ...............................             [ 66%]
tests/common/test_middleware.py ...                                      [ 67%]
tests/common/test_msgpack_packet.py ....                                 [ 67%]
tests/common/test_namespace.py ..................                        [ 70%]
tests/common/test_packet.py ......................................       [ 77%]
tests/common/test_pubsub_manager.py .................................... [ 83%]
                                                                         [ 83%]
tests/common/test_server.py ............................................ [ 91%]
................................                                         [ 97%]
tests/common/test_simple_client.py ................                      [100%]

=================================== FAILURES ===================================
_________________ TestAsyncAdmin.test_admin_connect_only_admin _________________

self = <tests.async.test_admin.TestAsyncAdmin testMethod=test_admin_connect_only_admin>
isvr = <socketio.async_admin.InstrumentedAsyncServer object at 0x7f99b62f9f40>

    @with_instrumented_server()
    def test_admin_connect_only_admin(self, isvr):
        with socketio.SimpleClient() as admin_client:
            admin_client.connect('http://localhost:8900', namespace='/admin')
            sid = admin_client.sid
            expected = ['config', 'all_sockets', 'server_stats']
            events = {}
            while expected:
                data = admin_client.receive(timeout=5)
                if data[0] in expected:
                    events[data[0]] = data[1]
                    expected.remove(data[0])

        assert 'supportedFeatures' in events['config']
        assert 'ALL_EVENTS' in events['config']['supportedFeatures']
        assert 'AGGREGATED_EVENTS' in events['config']['supportedFeatures']
        assert 'EMIT' in events['config']['supportedFeatures']
        assert len(events['all_sockets']) == 1
        assert events['all_sockets'][0]['id'] == sid
        assert events['all_sockets'][0]['rooms'] == [sid]
        assert events['server_stats']['clientsCount'] == 1
>       assert events['server_stats']['pollingClientsCount'] == 0
E       assert 1 == 0

tests/async/test_admin.py:187: AssertionError
----------------------------- Captured stdout call -----------------------------
threads at start: [<_MainThread(MainThread, started 140298428958528)>]
INFO:     127.0.0.1:39914 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:39926 - "GET /socket.io/?transport=polling&EIO=4&t=1698930315.8678105 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39926 - "POST /socket.io/?transport=polling&EIO=4&sid=6OQfQboDd74Ayw0cAAAA HTTP/1.1" 200 OK
INFO:     127.0.0.1:39938 - "GET /socket.io/?transport=polling&EIO=4&sid=6OQfQboDd74Ayw0cAAAA&t=1698930315.8764062 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39938 - "GET /socket.io/?transport=polling&EIO=4&sid=6OQfQboDd74Ayw0cAAAA&t=1698930315.8875527 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39938 - "GET /socket.io/?transport=polling&EIO=4&sid=6OQfQboDd74Ayw0cAAAA&t=1698930315.9865756 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39938 - "GET /socket.io/?transport=polling&EIO=4&sid=6OQfQboDd74Ayw0cAAAA&t=1698930315.9940076 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39938 - "POST /socket.io/?transport=polling&EIO=4&sid=6OQfQboDd74Ayw0cAAAA HTTP/1.1" 200 OK
INFO:     127.0.0.1:39926 - "GET /socket.io/?transport=polling&EIO=4&sid=6OQfQboDd74Ayw0cAAAA&t=1698930316.1271572 HTTP/1.1" 200 OK
threads at end: [<_MainThread(MainThread, started 140298428958528)>]
----------------------------- Captured stderr call -----------------------------
INFO:     Started server process [57042]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8900 (Press CTRL+C to quit)
websocket-client package not installed, only polling transport is available
INFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
INFO:     Finished server process [57042]
------------------------------ Captured log call -------------------------------
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
_________________ TestAsyncAdmin.test_admin_connect_production _________________

self = <tests.async.test_admin.TestAsyncAdmin testMethod=test_admin_connect_production>
isvr = <socketio.async_admin.InstrumentedAsyncServer object at 0x7f99b613d7f0>

    @with_instrumented_server(mode='production', read_only=True)
    def test_admin_connect_production(self, isvr):
        with socketio.SimpleClient() as admin_client:
            admin_client.connect('http://localhost:8900', namespace='/admin')
            expected = ['config', 'server_stats']
            events = {}
            while expected:
                data = admin_client.receive(timeout=5)
                if data[0] in expected:
                    events[data[0]] = data[1]
                    expected.remove(data[0])

        assert 'supportedFeatures' in events['config']
        assert 'ALL_EVENTS' not in events['config']['supportedFeatures']
        assert 'AGGREGATED_EVENTS' in events['config']['supportedFeatures']
        assert 'EMIT' not in events['config']['supportedFeatures']
        assert events['server_stats']['clientsCount'] == 1
>       assert events['server_stats']['pollingClientsCount'] == 0
E       assert 1 == 0

tests/async/test_admin.py:268: AssertionError
----------------------------- Captured stdout call -----------------------------
threads at start: [<_MainThread(MainThread, started 140298428958528)>]
INFO:     127.0.0.1:39960 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:39972 - "GET /socket.io/?transport=polling&EIO=4&t=1698930316.6057374 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39972 - "POST /socket.io/?transport=polling&EIO=4&sid=4W4vxxQeeKLG2hiEAAAA HTTP/1.1" 200 OK
INFO:     127.0.0.1:39974 - "GET /socket.io/?transport=polling&EIO=4&sid=4W4vxxQeeKLG2hiEAAAA&t=1698930316.6187785 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39974 - "GET /socket.io/?transport=polling&EIO=4&sid=4W4vxxQeeKLG2hiEAAAA&t=1698930316.6289947 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39974 - "GET /socket.io/?transport=polling&EIO=4&sid=4W4vxxQeeKLG2hiEAAAA&t=1698930316.7273962 HTTP/1.1" 200 OK
INFO:     127.0.0.1:39974 - "POST /socket.io/?transport=polling&EIO=4&sid=4W4vxxQeeKLG2hiEAAAA HTTP/1.1" 200 OK
INFO:     127.0.0.1:39972 - "GET /socket.io/?transport=polling&EIO=4&sid=4W4vxxQeeKLG2hiEAAAA&t=1698930316.8696787 HTTP/1.1" 500 Internal Server Error
threads at end: [<_MainThread(MainThread, started 140298428958528)>]
----------------------------- Captured stderr call -----------------------------
INFO:     Started server process [57042]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8900 (Press CTRL+C to quit)
websocket-client package not installed, only polling transport is available
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/engineio/async_drivers/asgi.py", line 58, in __call__
    await self.engineio_server.handle_request(scope, receive, send)
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-socketio-5.10.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/socketio/async_server.py", line 441, in handle_request
    return await self.eio.handle_request(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/engineio/async_server.py", line 278, in handle_request
    socket = self._get_socket(sid)
  File "/usr/lib/python3.8/site-packages/engineio/base_server.py", line 229, in _get_socket
    raise KeyError('Session is disconnected')
KeyError: 'Session is disconnected'
INFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
INFO:     Finished server process [57042]
------------------------------ Captured log call -------------------------------
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
________________ TestAsyncAdmin.test_admin_connect_with_others _________________

self = <tests.async.test_admin.TestAsyncAdmin testMethod=test_admin_connect_with_others>
isvr = <socketio.async_admin.InstrumentedAsyncServer object at 0x7f99b667a520>

    @with_instrumented_server()
    def test_admin_connect_with_others(self, isvr):
        with socketio.SimpleClient() as client1, \
                socketio.SimpleClient() as client2, \
                socketio.SimpleClient() as client3, \
                socketio.SimpleClient() as admin_client:
            client1.connect('http://localhost:8900')
            client1.emit('enter_room', 'room')
            sid1 = client1.sid

            saved_check_for_upgrade = isvr._check_for_upgrade
            isvr._check_for_upgrade = AsyncMock()
            client2.connect('http://localhost:8900', namespace='/foo',
                            transports=['polling'])
            sid2 = client2.sid
            isvr._check_for_upgrade = saved_check_for_upgrade

            client3.connect('http://localhost:8900', namespace='/admin')
            sid3 = client3.sid

            admin_client.connect('http://localhost:8900', namespace='/admin')
            sid = admin_client.sid
            expected = ['config', 'all_sockets', 'server_stats']
            events = {}
            while expected:
                data = admin_client.receive(timeout=5)
                if data[0] in expected:
                    events[data[0]] = data[1]
                    expected.remove(data[0])

        assert 'supportedFeatures' in events['config']
        assert 'ALL_EVENTS' in events['config']['supportedFeatures']
        assert 'AGGREGATED_EVENTS' in events['config']['supportedFeatures']
        assert 'EMIT' in events['config']['supportedFeatures']
        assert len(events['all_sockets']) == 4
        assert events['server_stats']['clientsCount'] == 4
>       assert events['server_stats']['pollingClientsCount'] == 1
E       assert 4 == 1

tests/async/test_admin.py:232: AssertionError
----------------------------- Captured stdout call -----------------------------
threads at start: [<_MainThread(MainThread, started 140298428958528)>]
INFO:     127.0.0.1:35248 - "GET / HTTP/1.1" 200 OK
INFO:     127.0.0.1:35254 - "GET /socket.io/?transport=polling&EIO=4&t=1698930518.7994537 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35254 - "POST /socket.io/?transport=polling&EIO=4&sid=DHipojRhQBVzKVf7AAAA HTTP/1.1" 200 OK
INFO:     127.0.0.1:35258 - "GET /socket.io/?transport=polling&EIO=4&sid=DHipojRhQBVzKVf7AAAA&t=1698930518.8143053 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35254 - "POST /socket.io/?transport=polling&EIO=4&sid=DHipojRhQBVzKVf7AAAA HTTP/1.1" 200 OK
INFO:     127.0.0.1:35270 - "GET /socket.io/?transport=polling&EIO=4&t=1698930518.8261983 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35270 - "POST /socket.io/?transport=polling&EIO=4&sid=r8fEZxoMgVl4eDicAAAC HTTP/1.1" 200 OK
INFO:     127.0.0.1:35274 - "GET /socket.io/?transport=polling&EIO=4&sid=r8fEZxoMgVl4eDicAAAC&t=1698930518.8443348 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35276 - "GET /socket.io/?transport=polling&EIO=4&t=1698930518.8555653 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35276 - "POST /socket.io/?transport=polling&EIO=4&sid=nkqmen-1e4riNaTxAAAE HTTP/1.1" 200 OK
INFO:     127.0.0.1:35278 - "GET /socket.io/?transport=polling&EIO=4&sid=nkqmen-1e4riNaTxAAAE&t=1698930518.8701632 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35284 - "GET /socket.io/?transport=polling&EIO=4&t=1698930518.8838327 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35284 - "POST /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG HTTP/1.1" 200 OK
INFO:     127.0.0.1:35278 - "GET /socket.io/?transport=polling&EIO=4&sid=nkqmen-1e4riNaTxAAAE&t=1698930518.8816657 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35300 - "GET /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG&t=1698930518.9019713 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35278 - "GET /socket.io/?transport=polling&EIO=4&sid=nkqmen-1e4riNaTxAAAE&t=1698930518.908574 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35300 - "GET /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG&t=1698930518.9162633 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35300 - "GET /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG&t=1698930518.9906971 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35300 - "GET /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG&t=1698930519.012215 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35278 - "GET /socket.io/?transport=polling&EIO=4&sid=nkqmen-1e4riNaTxAAAE&t=1698930518.982617 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35300 - "GET /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG&t=1698930519.021495 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35278 - "GET /socket.io/?transport=polling&EIO=4&sid=nkqmen-1e4riNaTxAAAE&t=1698930519.0645232 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35300 - "POST /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG HTTP/1.1" 200 OK
INFO:     127.0.0.1:35284 - "GET /socket.io/?transport=polling&EIO=4&sid=00tHplKimsSGfpYbAAAG&t=1698930519.0711331 HTTP/1.1" 200 OK
INFO:     127.0.0.1:35254 - "POST /socket.io/?transport=polling&EIO=4&sid=DHipojRhQBVzKVf7AAAA HTTP/1.1" 200 OK
INFO:     127.0.0.1:35270 - "POST /socket.io/?transport=polling&EIO=4&sid=r8fEZxoMgVl4eDicAAAC HTTP/1.1" 200 OK
threads at end: [<_MainThread(MainThread, started 140298428958528)>]
----------------------------- Captured stderr call -----------------------------
INFO:     Started server process [57042]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8900 (Press CTRL+C to quit)
websocket-client package not installed, only polling transport is available
websocket-client package not installed, only polling transport is available
websocket-client package not installed, only polling transport is available
INFO:     Shutting down
INFO:     Waiting for connections to close. (CTRL+C to force quit)
INFO:     Waiting for background tasks to complete. (CTRL+C to force quit)
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
INFO:     Finished server process [57042]
------------------------------ Captured log call -------------------------------
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
___________________ TestAdmin.test_admin_connect_only_admin ____________________

self = <tests.common.test_admin.TestAdmin testMethod=test_admin_connect_only_admin>
isvr = <socketio.admin.InstrumentedServer object at 0x7f99b62bcd60>

    @with_instrumented_server()
    def test_admin_connect_only_admin(self, isvr):
        with socketio.SimpleClient() as admin_client:
            admin_client.connect('http://localhost:8900', namespace='/admin')
            sid = admin_client.sid
            expected = ['config', 'all_sockets', 'server_stats']
            events = {}
            while expected:
                data = admin_client.receive(timeout=5)
                if data[0] in expected:
                    events[data[0]] = data[1]
                    expected.remove(data[0])

        assert 'supportedFeatures' in events['config']
        assert 'ALL_EVENTS' in events['config']['supportedFeatures']
        assert 'AGGREGATED_EVENTS' in events['config']['supportedFeatures']
        assert 'EMIT' in events['config']['supportedFeatures']
        assert len(events['all_sockets']) == 1
        assert events['all_sockets'][0]['id'] == sid
        assert events['all_sockets'][0]['rooms'] == [sid]
        assert events['server_stats']['clientsCount'] == 1
>       assert events['server_stats']['pollingClientsCount'] == 0
E       assert 1 == 0

tests/common/test_admin.py:162: AssertionError
----------------------------- Captured stdout call -----------------------------
threads at start: [<_MainThread(MainThread, started 140298428958528)>]
threads at end: [<_MainThread(MainThread, started 140298428958528)>]
----------------------------- Captured stderr call -----------------------------
127.0.0.1 - - [02/Nov/2023 13:10:10] "GET / HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:10:10] "GET /socket.io/?transport=polling&EIO=4&t=1698930610.6052804 HTTP/1.1" 200 97
websocket-client package not installed, only polling transport is available
127.0.0.1 - - [02/Nov/2023 13:10:10] "POST /socket.io/?transport=polling&EIO=4&sid=3c1tfqkNNkNGkosFAAAA HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:10:10] "GET /socket.io/?transport=polling&EIO=4&sid=3c1tfqkNNkNGkosFAAAA&t=1698930610.6128032 HTTP/1.1" 200 705
127.0.0.1 - - [02/Nov/2023 13:10:10] "GET /socket.io/?transport=polling&EIO=4&sid=3c1tfqkNNkNGkosFAAAA&t=1698930610.6216378 HTTP/1.1" 200 665
127.0.0.1 - - [02/Nov/2023 13:10:10] "GET /socket.io/?transport=polling&EIO=4&sid=3c1tfqkNNkNGkosFAAAA&t=1698930610.7210798 HTTP/1.1" 200 580
------------------------------ Captured log call -------------------------------
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
___________________ TestAdmin.test_admin_connect_production ____________________

self = <tests.common.test_admin.TestAdmin testMethod=test_admin_connect_production>
isvr = <socketio.admin.InstrumentedServer object at 0x7f99b6558640>

    @with_instrumented_server(mode='production', read_only=True)
    def test_admin_connect_production(self, isvr):
        with socketio.SimpleClient() as admin_client:
            admin_client.connect('http://localhost:8900', namespace='/admin')
            expected = ['config', 'server_stats']
            events = {}
            while expected:
                data = admin_client.receive(timeout=5)
                if data[0] in expected:
                    events[data[0]] = data[1]
                    expected.remove(data[0])

        assert 'supportedFeatures' in events['config']
        assert 'ALL_EVENTS' not in events['config']['supportedFeatures']
        assert 'AGGREGATED_EVENTS' in events['config']['supportedFeatures']
        assert 'EMIT' not in events['config']['supportedFeatures']
        assert events['server_stats']['clientsCount'] == 1
>       assert events['server_stats']['pollingClientsCount'] == 0
E       assert 1 == 0

tests/common/test_admin.py:243: AssertionError
----------------------------- Captured stdout call -----------------------------
threads at start: [<_MainThread(MainThread, started 140298428958528)>]
threads at end: [<_MainThread(MainThread, started 140298428958528)>]
----------------------------- Captured stderr call -----------------------------
127.0.0.1 - - [02/Nov/2023 13:10:11] "GET / HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:10:11] "GET /socket.io/?transport=polling&EIO=4&t=1698930611.1550329 HTTP/1.1" 200 97
websocket-client package not installed, only polling transport is available
127.0.0.1 - - [02/Nov/2023 13:10:11] "POST /socket.io/?transport=polling&EIO=4&sid=DlZRZp45WfoSpvTcAAAA HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:10:11] "GET /socket.io/?transport=polling&EIO=4&sid=DlZRZp45WfoSpvTcAAAA&t=1698930611.1682162 HTTP/1.1" 200 39
127.0.0.1 - - [02/Nov/2023 13:10:11] "GET /socket.io/?transport=polling&EIO=4&sid=DlZRZp45WfoSpvTcAAAA&t=1698930611.1755276 HTTP/1.1" 200 63
127.0.0.1 - - [02/Nov/2023 13:10:11] "GET /socket.io/?transport=polling&EIO=4&sid=DlZRZp45WfoSpvTcAAAA&t=1698930611.2739904 HTTP/1.1" 200 577
------------------------------ Captured log call -------------------------------
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
___________________ TestAdmin.test_admin_connect_with_others ___________________

self = <tests.common.test_admin.TestAdmin testMethod=test_admin_connect_with_others>
isvr = <socketio.admin.InstrumentedServer object at 0x7f99b5449160>

    @with_instrumented_server()
    def test_admin_connect_with_others(self, isvr):
        with socketio.SimpleClient() as client1, \
                socketio.SimpleClient() as client2, \
                socketio.SimpleClient() as client3, \
                socketio.SimpleClient() as admin_client:
            client1.connect('http://localhost:8900')
            client1.emit('enter_room', 'room')
            sid1 = client1.sid

            saved_check_for_upgrade = isvr._check_for_upgrade
            isvr._check_for_upgrade = mock.MagicMock()
            client2.connect('http://localhost:8900', namespace='/foo',
                            transports=['polling'])
            sid2 = client2.sid
            isvr._check_for_upgrade = saved_check_for_upgrade

            client3.connect('http://localhost:8900', namespace='/admin')
            sid3 = client3.sid

            admin_client.connect('http://localhost:8900', namespace='/admin')
            sid = admin_client.sid
            expected = ['config', 'all_sockets', 'server_stats']
            events = {}
            while expected:
                data = admin_client.receive(timeout=5)
                if data[0] in expected:
                    events[data[0]] = data[1]
                    expected.remove(data[0])

        assert 'supportedFeatures' in events['config']
        assert 'ALL_EVENTS' in events['config']['supportedFeatures']
        assert 'AGGREGATED_EVENTS' in events['config']['supportedFeatures']
        assert 'EMIT' in events['config']['supportedFeatures']
        assert len(events['all_sockets']) == 4
        assert events['server_stats']['clientsCount'] == 4
>       assert events['server_stats']['pollingClientsCount'] == 1
E       assert 4 == 1

tests/common/test_admin.py:207: AssertionError
----------------------------- Captured stdout call -----------------------------
threads at start: [<_MainThread(MainThread, started 140298428958528)>]
threads at end: [<_MainThread(MainThread, started 140298428958528)>]
----------------------------- Captured stderr call -----------------------------
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET / HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&t=1698930762.5861912 HTTP/1.1" 200 97
websocket-client package not installed, only polling transport is available
127.0.0.1 - - [02/Nov/2023 13:12:42] "POST /socket.io/?transport=polling&EIO=4&sid=eDQ86lzYKTYTi3-HAAAA HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=eDQ86lzYKTYTi3-HAAAA&t=1698930762.5993142 HTTP/1.1" 200 32
127.0.0.1 - - [02/Nov/2023 13:12:42] "POST /socket.io/?transport=polling&EIO=4&sid=eDQ86lzYKTYTi3-HAAAA HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&t=1698930762.6099381 HTTP/1.1" 200 97
127.0.0.1 - - [02/Nov/2023 13:12:42] "POST /socket.io/?transport=polling&EIO=4&sid=TdGjHJdfh0pgXsvvAAAC HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=TdGjHJdfh0pgXsvvAAAC&t=1698930762.6267276 HTTP/1.1" 200 37
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&t=1698930762.634602 HTTP/1.1" 200 97
websocket-client package not installed, only polling transport is available
127.0.0.1 - - [02/Nov/2023 13:12:42] "POST /socket.io/?transport=polling&EIO=4&sid=2dGQzAWZi1yjTpYqAAAE HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=2dGQzAWZi1yjTpYqAAAE&t=1698930762.647121 HTTP/1.1" 200 703
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&t=1698930762.6575818 HTTP/1.1" 200 97
websocket-client package not installed, only polling transport is available
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=2dGQzAWZi1yjTpYqAAAE&t=1698930762.6577694 HTTP/1.1" 200 665
127.0.0.1 - - [02/Nov/2023 13:12:42] "POST /socket.io/?transport=polling&EIO=4&sid=dvz_qt-EOYj1hLdtAAAG HTTP/1.1" 200 2
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=dvz_qt-EOYj1hLdtAAAG&t=1698930762.666756 HTTP/1.1" 200 705
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=2dGQzAWZi1yjTpYqAAAE&t=1698930762.6755328 HTTP/1.1" 200 142
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=dvz_qt-EOYj1hLdtAAAG&t=1698930762.6784272 HTTP/1.1" 200 569
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=dvz_qt-EOYj1hLdtAAAG&t=1698930762.76182 HTTP/1.1" 200 658
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=2dGQzAWZi1yjTpYqAAAE&t=1698930762.7581413 HTTP/1.1" 200 581
127.0.0.1 - - [02/Nov/2023 13:12:42] "GET /socket.io/?transport=polling&EIO=4&sid=dvz_qt-EOYj1hLdtAAAG&t=1698930762.7779737 HTTP/1.1" 200 581
------------------------------ Captured log call -------------------------------
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
ERROR    engineio.client:client.py:233 websocket-client package not installed, only polling transport is available
=============================== warnings summary ===============================
tests/async/test_client.py::TestAsyncClient::test_handle_reconnect_aborted
tests/async/test_pubsub_manager.py::TestAsyncPubSubManager::test_emit_with_ignore_queue
  /usr/lib64/python3.8/unittest/mock.py:2030: RuntimeWarning: coroutine 'Event.wait' was never awaited
    setattr(_type, entry, MagicProxy(entry, self))
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/async/test_client.py::TestAsyncClient::test_wait_reconnect_successful
  /usr/lib64/python3.8/enum.py:339: RuntimeWarning: coroutine 'Event.wait' was never awaited
    return cls.__new__(cls, value)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/async/test_manager.py::TestAsyncManager::test_close_invalid_room
  /home/tkloczko/rpmbuild/BUILD/python-socketio-5.10.0/tests/async/test_manager.py:195: RuntimeWarning: coroutine 'AsyncManager.close_room' was never awaited
    self.bm.close_room('bar', '/foo')
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/async/test_pubsub_manager.py::TestAsyncPubSubManager::test_emit_with_ignore_queue
  /usr/lib64/python3.8/unittest/mock.py:2030: RuntimeWarning: coroutine 'TestAsyncClient.test_wait_reconnect_successful.<locals>.fake_wait' was never awaited
    setattr(_type, entry, MagicProxy(entry, self))
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/async/test_admin.py::TestAsyncAdmin::test_admin_connect_only_admin
FAILED tests/async/test_admin.py::TestAsyncAdmin::test_admin_connect_production
FAILED tests/async/test_admin.py::TestAsyncAdmin::test_admin_connect_with_others
FAILED tests/common/test_admin.py::TestAdmin::test_admin_connect_only_admin
FAILED tests/common/test_admin.py::TestAdmin::test_admin_connect_production
FAILED tests/common/test_admin.py::TestAdmin::test_admin_connect_with_others
============ 6 failed, 564 passed, 5 warnings in 539.42s (0:08:59) =============

Here is list of installed modules in build env

Package                       Version
----------------------------- -------
alabaster                     0.7.13
Babel                         2.13.1
bidict                        0.22.1
build                         1.0.3
charset-normalizer            3.3.2
click                         8.1.7
cppclean                      0.13
distro                        1.8.0
docutils                      0.20.1
exceptiongroup                1.1.3
gpg                           1.23.0
h11                           0.14.0
idna                          3.4
imagesize                     1.4.1
importlib-metadata            6.8.0
iniconfig                     2.0.0
installer                     0.7.0
Jinja2                        3.1.2
MarkupSafe                    2.1.3
msgpack                       1.0.6
packaging                     23.2
pluggy                        1.3.0
Pygments                      2.16.1
pyproject_hooks               1.0.0
pytest                        7.4.3
python-dateutil               2.8.2
python-engineio               4.8.0
pytz                          2023.3
requests                      2.31.0
setuptools                    68.2.2
simple-websocket              1.0.0
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        7.1.2
sphinxcontrib-applehelp       1.0.4
sphinxcontrib-devhelp         1.0.5
sphinxcontrib-htmlhelp        2.0.4
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.9
tomli                         2.0.1
typing_extensions             4.8.0
urllib3                       1.26.18
uvicorn                       0.24.0
wheel                         0.41.3
wsproto                       1.2.0
zipp                          3.17.0
@miguelgrinberg
Copy link
Owner

See tox.ini for the list of packages that need to be installed for unit tests.

@kloczek
Copy link
Author

kloczek commented Nov 5, 2023

Looks like only missing module was websocket-client and aiohttp (looks like pytest-timeout and requests not been used)

Thank you for the hints 👍 😄

After add those module fixed pytest which now is finishing with exit 0 however I see some warnings

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-socketio-5.10.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-socketio-5.10.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/python-socketio-5.10.0
plugins: timeout-2.2.0
collected 570 items

tests/async/test_admin.py ..........                                                                                                                                                  [  1%]
tests/async/test_client.py .......................................................................                                                                                    [ 14%]
tests/async/test_manager.py ..............................                                                                                                                            [ 19%]
tests/async/test_namespace.py .....................                                                                                                                                   [ 23%]
tests/async/test_pubsub_manager.py ..................................                                                                                                                 [ 29%]
tests/async/test_server.py .........................................................................                                                                                  [ 41%]
tests/async/test_simple_client.py ................                                                                                                                                    [ 44%]
tests/common/test_admin.py .........                                                                                                                                                  [ 46%]
tests/common/test_client.py ....................................................................................                                                                      [ 61%]
tests/common/test_manager.py ...............................                                                                                                                          [ 66%]
tests/common/test_middleware.py ...                                                                                                                                                   [ 67%]
tests/common/test_msgpack_packet.py ....                                                                                                                                              [ 67%]
tests/common/test_namespace.py ..................                                                                                                                                     [ 70%]
tests/common/test_packet.py ......................................                                                                                                                    [ 77%]
tests/common/test_pubsub_manager.py ....................................                                                                                                              [ 83%]
tests/common/test_server.py ............................................................................                                                                              [ 97%]
tests/common/test_simple_client.py ................                                                                                                                                   [100%]

===================================================================================== warnings summary ======================================================================================
tests/async/test_client.py::TestAsyncClient::test_send
  /usr/lib64/python3.8/unittest/mock.py:526: RuntimeWarning: coroutine 'Event.wait' was never awaited
    ret = self._get_child_mock(
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/async/test_client.py::TestAsyncClient::test_trigger_event
  /usr/lib64/python3.8/unittest/mock.py:2076: RuntimeWarning: coroutine 'Event.wait' was never awaited
    self.name = name
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/async/test_manager.py::TestAsyncManager::test_close_invalid_room
  /home/tkloczko/rpmbuild/BUILD/python-socketio-5.10.0/tests/async/test_manager.py:195: RuntimeWarning: coroutine 'AsyncManager.close_room' was never awaited
    self.bm.close_room('bar', '/foo')
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/async/test_manager.py::TestAsyncManager::test_disconnect_with_callbacks
  /usr/lib64/python3.8/unittest/mock.py:2030: RuntimeWarning: coroutine 'TestAsyncClient.test_wait_reconnect_successful.<locals>.fake_wait' was never awaited
    setattr(_type, entry, MagicProxy(entry, self))
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================== 570 passed, 4 warnings in 128.87s (0:02:08) ========================================================================

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Nov 6, 2023

@kloczek the same warnings exist in the official builds. I will look at them.

@kloczek
Copy link
Author

kloczek commented Nov 11, 2023

Thank you for the confirmation 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants