PYTHON-5114 Test suite reduce killAllSessions calls (#2721)

This commit is contained in:
Shane Harvey 2026-03-09 11:53:40 -07:00 committed by GitHub
parent 38da6c3f9a
commit f303125cee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 10 deletions

View File

@ -1464,11 +1464,6 @@ class UnifiedSpecTestMixinV1(AsyncIntegrationTest):
self.assertListEqual(sorted_expected_documents, actual_documents) self.assertListEqual(sorted_expected_documents, actual_documents)
async def run_scenario(self, spec, uri=None): async def run_scenario(self, spec, uri=None):
# Kill all sessions before and after each test to prevent an open
# transaction (from a test failure) from blocking collection/database
# operations during test set up and tear down.
await self.kill_all_sessions()
# Handle flaky tests. # Handle flaky tests.
flaky_tests = [ flaky_tests = [
("PYTHON-5170", ".*test_discovery_and_monitoring.*"), ("PYTHON-5170", ".*test_discovery_and_monitoring.*"),
@ -1504,6 +1499,15 @@ class UnifiedSpecTestMixinV1(AsyncIntegrationTest):
if skip_reason is not None: if skip_reason is not None:
raise unittest.SkipTest(f"{skip_reason}") raise unittest.SkipTest(f"{skip_reason}")
# Kill all sessions after each test with transactions to prevent an open
# transaction (from a test failure) from blocking collection/database
# operations during test set up and tear down.
for op in spec["operations"]:
name = op["name"]
if name == "startTransaction" or name == "withTransaction":
self.addAsyncCleanup(self.kill_all_sessions)
break
# process createEntities # process createEntities
self._uri = uri self._uri = uri
self.entity_map = EntityMapUtil(self) self.entity_map = EntityMapUtil(self)

View File

@ -1451,11 +1451,6 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
self.assertListEqual(sorted_expected_documents, actual_documents) self.assertListEqual(sorted_expected_documents, actual_documents)
def run_scenario(self, spec, uri=None): def run_scenario(self, spec, uri=None):
# Kill all sessions before and after each test to prevent an open
# transaction (from a test failure) from blocking collection/database
# operations during test set up and tear down.
self.kill_all_sessions()
# Handle flaky tests. # Handle flaky tests.
flaky_tests = [ flaky_tests = [
("PYTHON-5170", ".*test_discovery_and_monitoring.*"), ("PYTHON-5170", ".*test_discovery_and_monitoring.*"),
@ -1491,6 +1486,15 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
if skip_reason is not None: if skip_reason is not None:
raise unittest.SkipTest(f"{skip_reason}") raise unittest.SkipTest(f"{skip_reason}")
# Kill all sessions after each test with transactions to prevent an open
# transaction (from a test failure) from blocking collection/database
# operations during test set up and tear down.
for op in spec["operations"]:
name = op["name"]
if name == "startTransaction" or name == "withTransaction":
self.addCleanup(self.kill_all_sessions)
break
# process createEntities # process createEntities
self._uri = uri self._uri = uri
self.entity_map = EntityMapUtil(self) self.entity_map = EntityMapUtil(self)