diff --git a/test/test_topology.py b/test/test_topology.py index f2e7a91cda..c87c48819e 100644 --- a/test/test_topology.py +++ b/test/test_topology.py @@ -23,7 +23,7 @@ from test import client_knobs, unittest from test.pymongo_mocks import DummyMonitor -from test.utils import MockPool, flaky +from test.utils import MockPool from test.utils_shared import wait_until from bson.objectid import ObjectId @@ -755,7 +755,6 @@ def get_primary(): class TestTopologyErrors(TopologyTest): # Errors when calling hello. - @flaky(reason="PYTHON-5366") def test_pool_reset(self): # hello succeeds at first, then always raises socket error. hello_count = [0] @@ -776,7 +775,11 @@ def _check_with_socket(self, *args, **kwargs): # Pool is reset by hello failure. t.request_check_all() - self.assertNotEqual(generation, server.pool.gen.get_overall()) + # Wait for the monitor's hello failure to trigger Pool.reset() and bump the generation. + wait_until( + lambda: server.pool.gen.get_overall() != generation, + "pool reset after failed monitor check", + ) def test_hello_retry(self): # hello succeeds at first, then raises socket error, then succeeds.