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

Resolve integration test warnings from websocket connections #685

Closed
data-sync-user opened this issue Apr 22, 2024 · 1 comment
Closed

Comments

@data-sync-user
Copy link
Collaborator

data-sync-user commented Apr 22, 2024

There are several warnings issued when running integration tests. Three are deprecation notices due to some library deprecations, but the remainder are intermittent websocket warnings (examples below). This entails either resolving the warnings or silencing them if they are not of any concern.

Task was destroyed but it is pending!
task: <Task pending name='Task-335' coro=<WebSocketCommonProtocol.transfer_data() running at /Users/taddeskorris/.pyenv/versions/3.12.0/envs/push312/lib/python3.12/site-packages/websockets/legacy/protocol.py:963> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[Task.task_wakeup()]>
Task was destroyed but it is pending!
task: <Task pending name='Task-336' coro=<WebSocketCommonProtocol.keepalive_ping() running at /Users/taddeskorris/.pyenv/versions/3.12.0/envs/push312/lib/python3.12/site-packages/websockets/legacy/protocol.py:1254> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Task was destroyed but it is pending!
task: <Task pending name='Task-337' coro=<WebSocketCommonProtocol.close_connection() running at /Users/taddeskorris/.pyenv/versions/3.12.0/envs/push312/lib/python3.12/site-packages/websockets/legacy/protocol.py:1301> wait_for=<Task pending name='Task-335' coro=<WebSocketCommonProtocol.transfer_data() running at /Users/taddeskorris/.pyenv/versions/3.12.0/envs/push312/lib/python3.12/site-packages/websockets/legacy/protocol.py:963> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[Task.task_wakeup()]>>
Exception ignored in: <coroutine object WebSocketCommonProtocol.close_connection at 0x10a08b370>
Traceback (most recent call last):
  File "/Users/taddeskorris/.pyenv/versions/3.12.0/envs/push312/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1337, in close_connection
    await self.close_transport()
  File "/Users/taddeskorris/.pyenv/versions/3.12.0/envs/push312/lib/python3.12/site-packages/websockets/legacy/protocol.py", line 1353, in close_transport
    self.transport.close()
  File "/Users/taddeskorris/.pyenv/versions/3.12.0/lib/python3.12/asyncio/selector_events.py", line 1206, in close
    super().close()
  File "/Users/taddeskorris/.pyenv/versions/3.12.0/lib/python3.12/asyncio/selector_events.py", line 871, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "/Users/taddeskorris/.pyenv/versions/3.12.0/lib/python3.12/asyncio/base_events.py", line 772, in call_soon
    self._check_closed()
  File "/Users/taddeskorris/.pyenv/versions/3.12.0/lib/python3.12/asyncio/base_events.py", line 519, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Also a deprecation warning from some datetime functionality:

  /Users/taddeskorris/.pyenv/versions/3.12.0/envs/push312/lib/python3.12/site-packages/botocore/auth.py:419: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    datetime_now = datetime.datetime.utcnow()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 

Acceptance Criteria:

  • Ascertain the origin of these issues
  • Resolve the warnings or if they are unavoidable and of no impact to the tests, silence.
  • Have the tests run without signaling these warnings.

┆Issue is synchronized with this Jira Task

@data-sync-user
Copy link
Collaborator Author

➤ Taddes Korris commented:

The task https://mozilla-hub.atlassian.net/browse/SYNC-4116 ( https://mozilla-hub.atlassian.net/browse/SYNC-4116|smart-link ) which fixturizes the entire test suite to pytest spec actually resolves the async Event loop/ Co-routine issue. It is much simpler to roll the changes within that PR than make this one separate.

By utilizing fixtures to yield the websocket client, this allowed for explicit shutdown after each scoped test function. Also, the pytest-asyncio event loop plays nicely with async fixtures and the tests as expected, so this problem is resolved gracefully.

As for the warning regarding datetimes, this is a result of boto3 & botocore. After the DynamoDB implementation is removed, we won’t need this library so that issue will then be resolved.

As noted in boto/botocore#3038 ( https://github.com/boto/botocore/issues/3038|smart-link ) and boto/botocore#3145 ( https://github.com/boto/botocore/pull/3145|smart-link ) , this is a known issue with Python 3.12 that the team there has not resolved. Hence we don’t want to expend much effort resolving this given we’ll be removing this module anyway.

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

1 participant