@@ -111,7 +111,7 @@ def tearDown(self):
111
111
def get_nodelist (self , client ):
112
112
return client ._topology .description .server_descriptions ().keys ()
113
113
114
- def assert_nodelist_change (self , expected_nodelist , client ):
114
+ def assert_nodelist_change (self , expected_nodelist , client , timeout = ( 100 * WAIT_TIME ) ):
115
115
"""Check if the client._topology eventually sees all nodes in the
116
116
expected_nodelist.
117
117
"""
@@ -122,9 +122,9 @@ def predicate():
122
122
return True
123
123
return False
124
124
125
- wait_until (predicate , "see expected nodelist" , timeout = 100 * WAIT_TIME )
125
+ wait_until (predicate , "see expected nodelist" , timeout = timeout )
126
126
127
- def assert_nodelist_nochange (self , expected_nodelist , client ):
127
+ def assert_nodelist_nochange (self , expected_nodelist , client , timeout = ( 100 * WAIT_TIME ) ):
128
128
"""Check if the client._topology ever deviates from seeing all nodes
129
129
in the expected_nodelist. Consistency is checked after sleeping for
130
130
(WAIT_TIME * 10) seconds. Also check that the resolver is called at
@@ -136,7 +136,7 @@ def predicate():
136
136
return pymongo .srv_resolver ._SrvResolver .get_hosts_and_min_ttl .call_count >= 1
137
137
return False
138
138
139
- wait_until (predicate , "Node list equals expected nodelist" , timeout = 100 * WAIT_TIME )
139
+ wait_until (predicate , "Node list equals expected nodelist" , timeout = timeout )
140
140
141
141
nodelist = self .get_nodelist (client )
142
142
if set (expected_nodelist ) != set (nodelist ):
@@ -330,6 +330,22 @@ def nodelist_callback():
330
330
with SrvPollingKnobs (nodelist_callback = nodelist_callback ):
331
331
self .assert_nodelist_change (response , client )
332
332
333
+ def test_srv_waits_to_poll (self ):
334
+ modified = [("localhost.test.build.10gen.cc" , 27019 )]
335
+
336
+ def resolver_response ():
337
+ return modified
338
+
339
+ with SrvPollingKnobs (
340
+ ttl_time = WAIT_TIME ,
341
+ min_srv_rescan_interval = WAIT_TIME ,
342
+ nodelist_callback = resolver_response ,
343
+ ):
344
+ client = MongoClient (self .CONNECTION_STRING )
345
+ self .assertRaises (
346
+ AssertionError , self .assert_nodelist_change , modified , client , timeout = WAIT_TIME / 2
347
+ )
348
+
333
349
334
350
if __name__ == "__main__" :
335
351
unittest .main ()
0 commit comments