Skip to content

PYTHON-5905 - Make logging tests not fail due to PyPy GC issues#2934

Open
NoahStapp wants to merge 1 commit into
mongodb:masterfrom
NoahStapp:PYTHON-5905
Open

PYTHON-5905 - Make logging tests not fail due to PyPy GC issues#2934
NoahStapp wants to merge 1 commit into
mongodb:masterfrom
NoahStapp:PYTHON-5905

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

PYTHON-5905

Changes in this PR

PyPy's GC is non-deterministic, so cleanup commands from earlier tests can pollute the logs. Fixes this issue by filtering for the specific command and status we want before asserting.

Test Plan

Test changes.

Checklist

Checklist for Author

  • [ ] Did you update the changelog (if necessary)?
  • Is there test coverage?
  • [ ] Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

Copilot AI review requested due to automatic review settings July 10, 2026 19:01
@NoahStapp NoahStapp requested a review from a team as a code owner July 10, 2026 19:01
@NoahStapp NoahStapp requested a review from blink1073 July 10, 2026 19:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the command-logging truncation tests to be resilient to extra structured command logs that can appear under PyPy due to non-deterministic garbage collection triggering cleanup commands during test execution.

Changes:

  • Add a small helper (_get_command_log) to select the structured log entry matching a specific commandName and command status.
  • Replace brittle cm.records[N] indexing with filtered lookups for STARTED/SUCCEEDED/FAILED command logs in both sync and async logger tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/test_logger.py Uses a helper to locate the intended command log records before asserting truncation lengths (sync tests).
test/asynchronous/test_logger.py Mirrors the same robustness improvements for async logger tests.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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