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

UnitTest for blocking PubSub auto-reconnect #2256

Conversation

kristjanvalur
Copy link
Contributor

@kristjanvalur kristjanvalur commented Jun 27, 2022

Pull Request check-list

Please make sure to review and check all of these items:

  • Does $ tox pass with this change (including linting)?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?
  • Was the change added to CHANGES file?

_NOTE: Maybe this requires us to clarify the API, for it appears to be the intention that connections are automatically re-established.

Description of change

Issue #2089 is about automatic reconnection in async PubSub.
This PR adds unittests verifying how the connection in the synchronous PubSub will automatically reconnect.
The caller needs merely catch redis.ConnectionError and then retry the read operations and a new connection
will be established.

Two tests are provided, one which calls disconnect() on the underlying connection (and does not raise an error in the
reader) and one which mocks a socket.error coming out of the socket.recv() call.

@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2022

Codecov Report

Merging #2256 (a33a3a6) into master (e6cd4fd) will decrease coverage by 0.04%.
The diff coverage is 98.55%.

@@            Coverage Diff             @@
##           master    #2256      +/-   ##
==========================================
- Coverage   91.85%   91.81%   -0.05%     
==========================================
  Files         108      108              
  Lines       27783    27852      +69     
==========================================
+ Hits        25521    25572      +51     
- Misses       2262     2280      +18     
Impacted Files Coverage Δ
tests/test_pubsub.py 99.58% <98.55%> (-0.18%) ⬇️
tests/test_asyncio/test_bloom.py 94.57% <0.00%> (-1.36%) ⬇️
tests/test_bloom.py 98.24% <0.00%> (-1.32%) ⬇️
redis/asyncio/connection.py 83.18% <0.00%> (-0.89%) ⬇️
redis/commands/bf/commands.py 98.29% <0.00%> (-0.57%) ⬇️
tests/test_asyncio/test_search.py 98.35% <0.00%> (-0.33%) ⬇️
redis/connection.py 86.42% <0.00%> (ø)
tests/test_cluster.py 96.96% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e6cd4fd...a33a3a6. Read the comment docs.

@kristjanvalur kristjanvalur force-pushed the kristjan/sync-pubsub-auto-reconnect branch from 3614650 to a33a3a6 Compare June 27, 2022 14:23
@kristjanvalur kristjanvalur marked this pull request as ready for review June 27, 2022 14:34
@dvora-h
Copy link
Collaborator

dvora-h commented Jul 14, 2022

@kristjanvalur See test failure

@kristjanvalur
Copy link
Contributor Author

kristjanvalur commented Jul 15, 2022

Closing this PR in favour of another, (#2281) with better unit tests and suggested fixes.

@kristjanvalur kristjanvalur deleted the kristjan/sync-pubsub-auto-reconnect branch September 29, 2022 13:56
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

Successfully merging this pull request may close these issues.

3 participants