diff --git a/test/test_mongos_load_balancing.py b/test/test_mongos_load_balancing.py index b939abeb5..aface3dae 100644 --- a/test/test_mongos_load_balancing.py +++ b/test/test_mongos_load_balancing.py @@ -149,20 +149,20 @@ class TestMongosLoadBalancing(MockClientTest): writable_addresses(topology)) # No error - client.db.collection.find_one() + client.admin.command('ismaster') client = connected(self.mock_client(localThresholdMS=0)) self.assertEqual(0, client.local_threshold_ms) # No error - client.db.collection.find_one() + client.db.command('ismaster') # Our chosen mongos goes down. client.kill_host('%s:%s' % next(iter(client.nodes))) try: - client.db.collection.find_one() + client.db.command('ismaster') except: pass # No error - client.db.collection.find_one() + client.db.command('ismaster') def test_load_balancing(self): # Although the server selection JSON tests already prove that diff --git a/test/test_read_preferences.py b/test/test_read_preferences.py index f12818c1d..8bc6d6515 100644 --- a/test/test_read_preferences.py +++ b/test/test_read_preferences.py @@ -44,7 +44,7 @@ from test import (SkipTest, unittest, db_user, db_pwd) -from test.utils import single_client, one, wait_until, rs_client +from test.utils import connected, single_client, one, wait_until, rs_client from test.version import Version @@ -220,7 +220,11 @@ class TestReadPreferences(TestReadPreferencesBase): for ping_time, host in zip(ping_times, self.client.nodes): ServerDescription._host_to_round_trip_time[host] = ping_time try: - client = rs_client(readPreference='nearest', localThresholdMS=0) + client = connected( + rs_client(readPreference='nearest', localThresholdMS=0)) + wait_until( + lambda: client.nodes == self.client.nodes, + "discovered all nodes") host = self.read_from_which_host(client) for _ in range(5): self.assertEqual(host, self.read_from_which_host(client))