PYTHON-5975 Fix missing await calls in async test suite - #3029
Conversation
068b8dc to
b182c9b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Two async test bodies discarded coroutines instead of awaiting them, so the behavior under test never ran. test_reset_during_update_pool now drives its pool-reset loop with the ExceptionCatchingTask helper instead of a raw threading.Thread, which lets it drop require_sync. The retryable-writes listener schedules its fail point command as a task because a synchronous monitoring callback cannot await.
b182c9b to
1855b57
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A newly created asyncio task in the async command listener is not observed/exception-consumed, which can hide failures or produce “Task exception was never retrieved” warnings.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes missing/incorrect awaiting in the async test suite so tests do real work (instead of silently dropping coroutines) and surface background-task failures deterministically.
Changes:
- Updates
test_reset_during_update_pool(sync + async suites) to useExceptionCatchingTaskso the pool-reset loop actually runs and failures are asserted. - Removes the
require_syncgating ontest_reset_during_update_poolso it executes in the async suite. - Fixes
InsertEventListener.succeeded()in the async suite to avoid discarding an unawaitedadmin.command(...)coroutine by scheduling it withcreate_task.
File summaries
| File | Description |
|---|---|
| test/test_retryable_writes.py | Refactors failPoint configuration in InsertEventListener.succeeded() to avoid dropped work and align sync/async branching. |
| test/test_client.py | Replaces a bespoke reset-thread with ExceptionCatchingTask and asserts background errors; removes sync-only gating. |
| test/asynchronous/test_retryable_writes.py | Schedules async failPoint configuration with create_task instead of dropping an unawaited coroutine. |
| test/asynchronous/test_client.py | Uses ExceptionCatchingTask for async pool-reset loop so it runs concurrently and test failures are surfaced. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A done callback stores the scheduled fail point command's exception on the listener, and test_returns_original_error_code asserts it stayed None. An unobserved task exception otherwise leaves the test passing and surfaces only as a "Task exception was never retrieved" warning.
There was a problem hiding this comment.
🟢 Approval recommended
The changes are test-only and correctly make previously dropped async work observable, with only minor maintainability follow-ups suggested.
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Lite
PYTHON-5975
Changes in this PR
threading.Threadintest_reset_during_update_poolwithExceptionCatchingTask, so the pool-reset loop actually runs.require_sync, which existed only because of the raw thread.InsertEventListener.succeeded()to run itsconfigureFailPointcommand instead of dropping an unawaited coroutine.Test Plan
test_reset_during_update_poolwent fromSKIPPEDto passing in the async suite.test_returns_original_error_codepasses, and I confirmed the listener's fail point branch executes rather than passing vacuously.just lint,just synchro, andmypy --config-file mypy_test.iniare clean on all four files.create_taskbranch, which its ownrequire_syncstill gates. A synchronous monitoring callback cannot await, so nothing orders the fail point ahead of the retry it targets.Checklist
Checklist for Author
Checklist for Reviewer