Skip to content

PYTHON-5925 Fix flaky SRV polling monitor tests - #2924

Merged
blink1073 merged 2 commits into
mongodb:masterfrom
blink1073:PYTHON-5925
Jul 10, 2026
Merged

blink1073 merged 2 commits into
mongodb:masterfrom
blink1073:PYTHON-5925

Conversation

@blink1073

@blink1073 blink1073 commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

PYTHON-5925

Changes in this PR

Fixes the flakiness in test_dns_failures_logging. Also removes the now-unnecessary @flaky markers for PYTHON-5315 on the SRV seedlist recovery tests, since the underlying test-harness race conditions are resolved.

Test Plan

Verified locally (repeated runs) and Evergreen patch builds, including a full-matrix confirmation run targeting the previously-failing variants (win32/win64/pyopenssl-win64/etc.). The remaining failures there are pre-existing and unrelated to this change.

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?

blink1073 added 2 commits July 9, 2026 16:33
Fixes the flakiness in test_dns_failures_logging and removes the
now-unnecessary PYTHON-5315 flaky markers on the SRV seedlist
recovery tests.
Documents the FunctionCallRecorder sync/async recording-timing
difference, and drops a redundant re-check that duplicated the
preceding wait_until's condition.
@blink1073
blink1073 marked this pull request as ready for review July 9, 2026 22:35
@blink1073
blink1073 requested a review from a team as a code owner July 9, 2026 22:35
@blink1073
blink1073 requested review from NoahStapp and Copilot July 9, 2026 22:35

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

Reduces flakiness in SRV polling monitor tests by making log assertions resilient to timing, and by improving a shared test utility so recorded async calls represent coroutines that actually completed.

Changes:

  • Update FunctionCallRecorder to record coroutine invocations only after the coroutine finishes (success/exception/cancellation), and add descriptor support for method-style binding.
  • Fix test_dns_failures_logging (sync/async) by waiting until the expected “SRV monitor check failed” log record appears instead of asserting immediately.
  • Remove now-unnecessary @flaky markers from SRV seedlist recovery tests (sync/async).

Reviewed changes

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

File Description
test/utils_shared.py Refines FunctionCallRecorder semantics for async functions and adds __get__ for method binding.
test/test_srv_polling.py Replaces immediate log-count assertion with wait_until; removes @flaky usage.
test/asynchronous/test_srv_polling.py Async equivalent: uses async_wait_until; removes @flaky usage.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@blink1073
blink1073 merged commit a706c06 into mongodb:master Jul 10, 2026
88 checks passed
@blink1073
blink1073 deleted the PYTHON-5925 branch July 10, 2026 13:45
felixonmars added a commit to felixonmars/archriscv-packages that referenced this pull request Oct 4, 2026
Replace the scheduler-dependent 50 ms negative wait in test_srv_waits_to_poll, which fails with "AssertionError: AssertionError not raised" on riscv64. Client setup or delayed test execution can outlast the 100 ms polling interval before the negative wait completes.

Record the first seedlist poll and compare its monotonic timestamp with the monitor startup time plus the unchanged minimum interval, then require the topology update. Patch the async test and its generated sync counterpart without skipping tests or changing driver behavior. Apply the checksummed source patch in prepare() and retain the full pytest suite.

No matching upstream fix was found. PR #2924 is already included in 4.18.1 but fixes different SRV tests; the subsequent PR #3051 also leaves this timing assertion unchanged.

https://archriscv.felixc.at/.status/logs/python-pymongo/python-pymongo-4.18.1-1.log
https://github.com/mongodb/mongo-python-driver/blob/4.18.1/test/asynchronous/test_srv_polling.py#L362
https://github.com/mongodb/mongo-python-driver/blob/4.18.1/pymongo/synchronous/monitor.py#L345
mongodb/mongo-python-driver#2924
mongodb/mongo-python-driver#3051
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.

4 participants