Skip to content

PYTHON-5371 - Pass repr(ServerDescription) to logging #2329

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

Merged
merged 3 commits into from
May 8, 2025

Conversation

NoahStapp
Copy link
Contributor

@NoahStapp NoahStapp commented May 2, 2025

No description provided.

@NoahStapp NoahStapp requested a review from blink1073 May 2, 2025 14:38
@@ -1906,6 +1906,7 @@ async def test_direct_connection(self):
with self.assertRaises(ConfigurationError):
AsyncMongoClient(["host1", "host2"], directConnection=True)

@unittest.skipIf(os.environ.get("DEBUG_LOG"), "Enabling debug logs breaks this test")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this test break? I’m concerned about this pattern since it makes it harder to debug the test if it gets skipped. Could we leave a ticket open to come back to this test and make it work in debug mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were planning to replace this test with something less hacky in the future anyway. I can investigate deeper as to why this is breaking if we're planning to keep this test around instead.

@NoahStapp
Copy link
Contributor Author

NoahStapp commented May 2, 2025

Patch build with debug logs enabled without any failures of test_continuous_network_errors: https://spruce.mongodb.com/version/6814e3d321f66a0007561099/tasks?page=0&sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC&statuses=failed&taskName=%5E%28%28%3F%21pypy%29.%29%2A%24&variant=%5E%28%28%3F%21pypy%29.%29%2A%24

The fix was to pass ServerDescription.__repr__ instead of actual ServerDescription instances to our SDAM logger.

@NoahStapp NoahStapp requested a review from ShaneHarvey May 2, 2025 15:55
previousDescription=initial_td,
newDescription=self._description,
previousDescription=initial_td.__repr__(),
newDescription=self._description.__repr__(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update these to use repr() instead of __repr__?

@NoahStapp NoahStapp requested a review from ShaneHarvey May 8, 2025 18:06
Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Could you update the PR title?

@NoahStapp NoahStapp changed the title PYTHON-5371 - Skip test_continuous_network_errors when debug logs are… PYTHON-5371 - Pass repr(ServerDescription) to logging May 8, 2025
@NoahStapp NoahStapp merged commit 775b683 into mongodb:master May 8, 2025
31 checks passed
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.

2 participants