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

Disable retry in tests #9141

Closed
Dreamsorcerer opened this issue Sep 13, 2024 · 8 comments
Closed

Disable retry in tests #9141

Dreamsorcerer opened this issue Sep 13, 2024 · 8 comments
Assignees
Labels
enhancement Hacktoberfest We think it's good for https://hacktoberfest.digitalocean.com/

Comments

@Dreamsorcerer
Copy link
Member

Dreamsorcerer commented Sep 13, 2024

The client now has retry logic (

if retry_persistent_connection:
), but this logic can mask issues in tests.
We should disable the retry logic by default in tests (e.g. when using TestClient).

@Dreamsorcerer Dreamsorcerer added enhancement Hacktoberfest We think it's good for https://hacktoberfest.digitalocean.com/ labels Sep 13, 2024
@ShubhAgarwal-dev
Copy link
Contributor

Can I be assigned this? I will try to get this as part of the hacktoberfest event...

@Dreamsorcerer
Copy link
Member Author

Go ahead.

@ShubhAgarwal-dev
Copy link
Contributor

ShubhAgarwal-dev commented Oct 1, 2024

Hi Sam, this is my first time contributing to open-source and working with such a huge codebase. Can you guide me a bit on what is required to be done..?

@webknjaz
Copy link
Member

webknjaz commented Oct 1, 2024

@ShubhAgarwal-dev this needs understanding how the tests work, inspecting them and making sure they disable retries, essentially not hitting the block under the linked line of code. Perhaps, running the tests locally and generating an HTML coverage report would reveal which tests hit said line. What's needed is probably finding where TestClient is defined in code and making sure it defaults to initializing the client session with retries disabled.

@Dreamsorcerer perhaps we shouldn't mark issues as Hacktoberfest when they require deeper context?

@Dreamsorcerer
Copy link
Member Author

Well, basically we want the linked line in the original post to always be False. So, we could probably add a new argument to ClientSession, or a private attribute maybe which defaults that variable to True normally, but False in the tests.

The ClientSession for TestClient is created at:

self._session = ClientSession(cookie_jar=cookie_jar, **kwargs)

So, that's where we'll need to pass the parameter or modify the private attribute.

@Dreamsorcerer perhaps we shouldn't mark issues as Hacktoberfest when they require deeper context?

I think the above is sufficient, no need to verify coverage etc. or have deeper knowledge of the code. Once a rough implementation is ready, we can figure out a test to verify the behaviour.

@Dreamsorcerer
Copy link
Member Author

I'd probably suggest the private attribute initially, and keep it as an implementation detail. If users ask for this to be configurable in future, then we can consider adding a new parameter.

ShubhAgarwal-dev added a commit to ShubhAgarwal-dev/aiohttp that referenced this issue Oct 2, 2024
@ShubhAgarwal-dev
Copy link
Contributor

Is there anything left in this issue..?

@Dreamsorcerer
Copy link
Member Author

Ah, forgot to update the PR. If you include 'Fixes #9141' in the PR description next time, then the issue would be auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Hacktoberfest We think it's good for https://hacktoberfest.digitalocean.com/
Projects
None yet
Development

No branches or pull requests

3 participants