Skip to content

Commit 1cbd192

Browse files
authored
PYTHON-3995 Fix race in serverMonitoringMode test (#1393)
1 parent 81c759a commit 1cbd192

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

test/test_discovery_and_monitoring.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def test_pool_unpause(self):
342342
listener.wait_for_event(monitoring.PoolReadyEvent, 1)
343343

344344

345-
class TestSdamMode(IntegrationTest):
345+
class TestServerMonitoringMode(IntegrationTest):
346346
@client_context.require_no_serverless
347347
@client_context.require_no_load_balancer
348348
def setUp(self):
@@ -352,13 +352,21 @@ def test_rtt_connection_is_enabled_stream(self):
352352
client = rs_or_single_client(serverMonitoringMode="stream")
353353
self.addCleanup(client.close)
354354
client.admin.command("ping")
355-
for _, server in client._topology._servers.items():
356-
monitor = server._monitor
357-
self.assertTrue(monitor._stream)
358-
if client_context.version >= (4, 4):
359-
self.assertIsNotNone(monitor._rtt_monitor._executor._thread)
360-
else:
361-
self.assertIsNone(monitor._rtt_monitor._executor._thread)
355+
356+
def predicate():
357+
for _, server in client._topology._servers.items():
358+
monitor = server._monitor
359+
if not monitor._stream:
360+
return False
361+
if client_context.version >= (4, 4):
362+
if monitor._rtt_monitor._executor._thread is None:
363+
return False
364+
else:
365+
if monitor._rtt_monitor._executor._thread is not None:
366+
return False
367+
return True
368+
369+
wait_until(predicate, "find all RTT monitors")
362370

363371
def test_rtt_connection_is_disabled_poll(self):
364372
client = rs_or_single_client(serverMonitoringMode="poll")

0 commit comments

Comments
 (0)