PYTHON-915 - More robust tests.
This commit is contained in:
parent
f506d8b69f
commit
51cadce6fb
@ -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
|
||||
|
||||
@ -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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user