From 552b7bf47bbe6cf4a9532262e7234bea98f25402 Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Wed, 13 May 2026 12:20:15 -0400 Subject: [PATCH] =?UTF-8?q?PYTHON-5631=20-=20test=5Fdirect=5Fclient=5Fmain?= =?UTF-8?q?tains=5Fpool=5Fto=5Farbiter=20waits=20inst=E2=80=A6=20(#2798)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/asynchronous/test_client.py | 4 ++-- test/test_client.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/asynchronous/test_client.py b/test/asynchronous/test_client.py index ca150ca6d..dea1161af 100644 --- a/test/asynchronous/test_client.py +++ b/test/asynchronous/test_client.py @@ -2711,11 +2711,11 @@ class TestClientPool(AsyncMockClientTest): await async_wait_until(lambda: len(c.nodes) == 1, "connect") self.assertEqual(await c.address, ("c", 3)) - # Assert that we create 1 pooled connection. + # Wait for the pooled connection to be registered await listener.async_wait_for_event(monitoring.ConnectionReadyEvent, 1) self.assertEqual(listener.event_count(monitoring.ConnectionCreatedEvent), 1) arbiter = c._topology.get_server_by_address(("c", 3)) - self.assertEqual(len(arbiter.pool.conns), 1) + await async_wait_until(lambda: len(arbiter.pool.conns) == 1, "create 1 pooled connection") # Arbiter pool is marked ready. self.assertEqual(listener.event_count(monitoring.PoolReadyEvent), 1) diff --git a/test/test_client.py b/test/test_client.py index 75d585fda..d2d93c6ba 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -2666,11 +2666,11 @@ class TestClientPool(MockClientTest): wait_until(lambda: len(c.nodes) == 1, "connect") self.assertEqual(c.address, ("c", 3)) - # Assert that we create 1 pooled connection. + # Wait for the pooled connection to be registered listener.wait_for_event(monitoring.ConnectionReadyEvent, 1) self.assertEqual(listener.event_count(monitoring.ConnectionCreatedEvent), 1) arbiter = c._topology.get_server_by_address(("c", 3)) - self.assertEqual(len(arbiter.pool.conns), 1) + wait_until(lambda: len(arbiter.pool.conns) == 1, "create 1 pooled connection") # Arbiter pool is marked ready. self.assertEqual(listener.event_count(monitoring.PoolReadyEvent), 1)