Skip to content

Commit 85df5b6

Browse files
committed
Fix unified test client_knobs
1 parent 7d5688e commit 85df5b6

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

test/asynchronous/unified_format.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,21 @@ async def insert_initial_data(self, initial_data):
478478
# Ensure collection exists
479479
await db.create_collection(coll_name, write_concern=wc, **opts)
480480

481+
@classmethod
482+
def setUpClass(cls) -> None:
483+
# Speed up the tests by decreasing the heartbeat frequency.
484+
cls.knobs = client_knobs(
485+
heartbeat_frequency=0.1,
486+
min_heartbeat_interval=0.1,
487+
kill_cursor_frequency=0.1,
488+
events_queue_frequency=0.1,
489+
)
490+
cls.knobs.enable()
491+
492+
@classmethod
493+
def tearDownClass(cls) -> None:
494+
cls.knobs.disable()
495+
481496
async def asyncSetUp(self):
482497
# super call creates internal client cls.client
483498
await super().asyncSetUp()
@@ -503,15 +518,6 @@ async def asyncSetUp(self):
503518
for address in async_client_context.mongoses:
504519
self.mongos_clients.append(await self.async_single_client("{}:{}".format(*address)))
505520

506-
# Speed up the tests by decreasing the heartbeat frequency.
507-
self.knobs = client_knobs(
508-
heartbeat_frequency=0.1,
509-
min_heartbeat_interval=0.1,
510-
kill_cursor_frequency=0.1,
511-
events_queue_frequency=0.1,
512-
)
513-
self.knobs.enable()
514-
515521
# process schemaVersion
516522
# note: we check major schema version during class generation
517523
version = Version.from_string(self.TEST_SPEC["schemaVersion"])
@@ -525,7 +531,6 @@ async def asyncSetUp(self):
525531
self.match_evaluator = MatchEvaluatorUtil(self)
526532

527533
async def asyncTearDown(self):
528-
self.knobs.disable()
529534
for client in self.mongos_clients:
530535
await client.close()
531536
await super().asyncTearDown()

test/unified_format.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,21 @@ def insert_initial_data(self, initial_data):
477477
# Ensure collection exists
478478
db.create_collection(coll_name, write_concern=wc, **opts)
479479

480+
@classmethod
481+
def setUpClass(cls) -> None:
482+
# Speed up the tests by decreasing the heartbeat frequency.
483+
cls.knobs = client_knobs(
484+
heartbeat_frequency=0.1,
485+
min_heartbeat_interval=0.1,
486+
kill_cursor_frequency=0.1,
487+
events_queue_frequency=0.1,
488+
)
489+
cls.knobs.enable()
490+
491+
@classmethod
492+
def tearDownClass(cls) -> None:
493+
cls.knobs.disable()
494+
480495
def setUp(self):
481496
# super call creates internal client cls.client
482497
super().setUp()
@@ -502,15 +517,6 @@ def setUp(self):
502517
for address in client_context.mongoses:
503518
self.mongos_clients.append(self.single_client("{}:{}".format(*address)))
504519

505-
# Speed up the tests by decreasing the heartbeat frequency.
506-
self.knobs = client_knobs(
507-
heartbeat_frequency=0.1,
508-
min_heartbeat_interval=0.1,
509-
kill_cursor_frequency=0.1,
510-
events_queue_frequency=0.1,
511-
)
512-
self.knobs.enable()
513-
514520
# process schemaVersion
515521
# note: we check major schema version during class generation
516522
version = Version.from_string(self.TEST_SPEC["schemaVersion"])
@@ -524,7 +530,6 @@ def setUp(self):
524530
self.match_evaluator = MatchEvaluatorUtil(self)
525531

526532
def tearDown(self):
527-
self.knobs.disable()
528533
for client in self.mongos_clients:
529534
client.close()
530535
super().tearDown()

0 commit comments

Comments
 (0)