Skip to content

PYTHON-5974 Loosen baseBackoffMS prose test timing - #2967

Merged
NoahStapp merged 3 commits into
mongodb:mainfrom
NoahStapp:PYTHON-5974
Aug 3, 2026
Merged

PYTHON-5974 Loosen baseBackoffMS prose test timing#2967
NoahStapp merged 3 commits into
mongodb:mainfrom
NoahStapp:PYTHON-5974

Conversation

@NoahStapp

@NoahStapp NoahStapp commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PYTHON-5974

Changes in this PR

Loosens timing requirements for the affected test to allow for the slight variation seen between platforms. Asyncio running on Windows + Python <= 3.12 has a rougher granularity for loop timers that can cause the test to fail.

Test Plan

Test 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?

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 loosens the lower-bound timing assertions in the Client Backpressure spec test that measures baseBackoffMS-related retry delays, reducing test flakiness caused by timing variance across environments.

Changes:

  • Reduced the minimum expected duration for the default exponential backoff run (0.6s → 0.55s).
  • Reduced the minimum expected duration for the baseBackoffMS=50 run (0.3s → 0.25s).
  • Added an explanatory comment about timing slack (but currently phrased inconsistently with the assertions and the sync/async variants).

Reviewed changes

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

File Description
test/test_client_backpressure.py Loosens lower-bound timing assertions for the synchronous prose test.
test/asynchronous/test_client_backpressure.py Loosens lower-bound timing assertions for the asynchronous prose test.

Comment thread test/test_client_backpressure.py Outdated
Comment thread test/asynchronous/test_client_backpressure.py Outdated
@NoahStapp

Copy link
Copy Markdown
Contributor Author

auth-aws-ecs-macos is a known failure, will be resolved by our lockfile fix.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

# and the baseBackoffMS=50 backoffs are 0.1 + 0.2 = 0.3s.
self.assertGreaterEqual(exponential_backoff_time, 0.6)
self.assertGreaterEqual(with_base_backoff_ms_time, 0.3)
# Allow for slight timing slack due to asyncio timing resolution on Windows <= Python 3.12

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we only set the different timings in this scenario, to align with the spec otherwise?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@NoahStapp
NoahStapp requested a review from blink1073 August 3, 2026 13:27
self.assertGreaterEqual(with_base_backoff_ms_time, 0.3)

# Allow for slight timing slack on Windows + <= Python 3.12 due to asyncio timing resolution
if sys.platform == "win32" and not _IS_SYNC:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should also guard on the python version so we get the expected values on 3.13+

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whoops not sure how I missed that sorry.

@NoahStapp
NoahStapp requested a review from blink1073 August 3, 2026 14:00
@blink1073

Copy link
Copy Markdown
Member

SFP failures are tracked in https://jira.mongodb.org/browse/PYTHON-5984

@blink1073 blink1073 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@NoahStapp
NoahStapp merged commit e504eb6 into mongodb:main Aug 3, 2026
86 of 89 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.

4 participants