diff --git a/test/asynchronous/test_dns.py b/test/asynchronous/test_dns.py index 6c8e864a44..adb14c8862 100644 --- a/test/asynchronous/test_dns.py +++ b/test/asynchronous/test_dns.py @@ -153,6 +153,11 @@ async def run_test(self): await client.aconnect() if num_seeds is not None: self.assertEqual(len(client._topology_settings.seeds), num_seeds) + # For sharded clusters, wake every monitor now to ensure + # failed heartbeats retry quickly + # instead of waiting for the full 10-second heartbeat interval. + if async_client_context.is_mongos: + await client._topology.request_check_all() if hosts is not None: await async_wait_until( lambda: hosts == client.nodes, "match test hosts to client nodes" diff --git a/test/test_dns.py b/test/test_dns.py index bd7308c3d4..675fac1d81 100644 --- a/test/test_dns.py +++ b/test/test_dns.py @@ -153,6 +153,11 @@ def run_test(self): client._connect() if num_seeds is not None: self.assertEqual(len(client._topology_settings.seeds), num_seeds) + # For sharded clusters, wake every monitor now to ensure + # failed heartbeats retry quickly + # instead of waiting for the full 10-second heartbeat interval. + if client_context.is_mongos: + client._topology.request_check_all() if hosts is not None: wait_until(lambda: hosts == client.nodes, "match test hosts to client nodes") if num_hosts is not None: