PYTHON-5114 Test suite reduce killAllSessions calls#2721
PYTHON-5114 Test suite reduce killAllSessions calls#2721ShaneHarvey wants to merge 3 commits intomongodb:masterfrom
Conversation
| # operations during test set up and tear down. | ||
| await self.kill_all_sessions() | ||
| self.addAsyncCleanup(self.kill_all_sessions) | ||
| for op in test["operations"]: |
There was a problem hiding this comment.
Why do we have this in both unified_format and utils_spec_runner?
There was a problem hiding this comment.
There's a lot of duplication between the two. The legacy class should actually never be running any tests with transactions.
There was a problem hiding this comment.
Can we safely remove this code then?
There was a problem hiding this comment.
Right now yes? But it may be safer to keep it until we delete the remaining legacy tests. Just in case one of them is updated to include transaction operations.
There was a problem hiding this comment.
Fair enough. Can you open a ticket to track that final deletion?
There was a problem hiding this comment.
Oh looking at this again the SpecRunner class is unused so I removed it.
There was a problem hiding this comment.
Pull request overview
Refines the unified/spec test runners to reduce unnecessary killAllSessions calls by only scheduling session cleanup for tests that run transactions.
Changes:
- Removes unconditional
killAllSessionscalls that ran for every test. - Adds per-test detection of transactional operations to conditionally register
killAllSessionsas a cleanup. - Applies the same optimization to both synchronous and asynchronous unified/spec runners.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| test/utils_spec_runner.py | Conditionally registers killAllSessions cleanup only for tests that use transactions. |
| test/unified_format.py | Removes unconditional pre-test kill; adds conditional cleanup registration based on operations. |
| test/asynchronous/utils_spec_runner.py | Async equivalent: conditional addAsyncCleanup for transactional tests. |
| test/asynchronous/unified_format.py | Async unified runner: removes unconditional kill; adds conditional cleanup registration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
[PYTHON-5114]: Test suite reduce killAllSessions calls
Changes in this PR
Update the unified test runner to only run killAllSessions after tests that use transactions rather than before every single test. This provides 2 main benefits: