PYTHON-5974 Loosen baseBackoffMS prose test timing - #2967
Conversation
There was a problem hiding this comment.
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=50run (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. |
|
|
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 |
There was a problem hiding this comment.
Can we only set the different timings in this scenario, to align with the spec otherwise?
| 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: |
There was a problem hiding this comment.
I think we should also guard on the python version so we get the expected values on 3.13+
There was a problem hiding this comment.
Whoops not sure how I missed that sorry.
|
SFP failures are tracked in https://jira.mongodb.org/browse/PYTHON-5984 |
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 any followup work tracked in a JIRA ticket? If so, add link(s).Checklist for Reviewer