@@ -285,6 +285,7 @@ _test_topology_invalidate_server (bool pooled)
285
285
mongoc_server_description_t * fake_sd ;
286
286
mongoc_server_description_t * sd ;
287
287
mongoc_topology_description_t * td ;
288
+ mongoc_uri_t * uri ;
288
289
mongoc_client_t * client ;
289
290
mongoc_client_pool_t * pool = NULL ;
290
291
bson_error_t error ;
@@ -293,14 +294,18 @@ _test_topology_invalidate_server (bool pooled)
293
294
uint32_t id ;
294
295
mongoc_server_stream_t * server_stream ;
295
296
297
+ uri = test_framework_get_uri ();
298
+ /* no auto heartbeat */
299
+ mongoc_uri_set_option_as_int32 (uri , "heartbeatFrequencyMS" , INT32_MAX );
300
+
296
301
if (pooled ) {
297
- pool = test_framework_client_pool_new ( );
302
+ pool = mongoc_client_pool_new ( uri );
298
303
client = mongoc_client_pool_pop (pool );
299
304
300
305
/* background scanner complains about failed connection */
301
306
capture_logs (true);
302
307
} else {
303
- client = test_framework_client_new ( );
308
+ client = mongoc_client_new_from_uri ( uri );
304
309
}
305
310
306
311
td = & client -> topology -> description ;
@@ -309,9 +314,8 @@ _test_topology_invalidate_server (bool pooled)
309
314
server_stream =
310
315
mongoc_cluster_stream_for_reads (& client -> cluster , NULL , & error );
311
316
ASSERT_OR_PRINT (server_stream , error );
317
+ sd = server_stream -> sd ;
312
318
id = server_stream -> sd -> id ;
313
- sd = (mongoc_server_description_t * ) mongoc_set_get (td -> servers , id );
314
- BSON_ASSERT (sd );
315
319
BSON_ASSERT (sd -> type == MONGOC_SERVER_STANDALONE ||
316
320
sd -> type == MONGOC_SERVER_RS_PRIMARY ||
317
321
sd -> type == MONGOC_SERVER_MONGOS );
@@ -340,6 +344,7 @@ _test_topology_invalidate_server (bool pooled)
340
344
client -> topology -> scanner , & fake_host_list , fake_id );
341
345
BSON_ASSERT (!mongoc_cluster_stream_for_server (
342
346
& client -> cluster , fake_id , true, & error ));
347
+ mongoc_mutex_lock (& client -> topology -> mutex );
343
348
sd = (mongoc_server_description_t * ) mongoc_set_get (td -> servers , fake_id );
344
349
BSON_ASSERT (sd );
345
350
BSON_ASSERT (sd -> type == MONGOC_SERVER_UNKNOWN );
@@ -350,8 +355,10 @@ _test_topology_invalidate_server (bool pooled)
350
355
BSON_ASSERT (bson_empty (& sd -> passives ));
351
356
BSON_ASSERT (bson_empty (& sd -> arbiters ));
352
357
BSON_ASSERT (bson_empty (& sd -> compressors ));
358
+ mongoc_mutex_unlock (& client -> topology -> mutex );
353
359
354
360
mongoc_server_stream_cleanup (server_stream );
361
+ mongoc_uri_destroy (uri );
355
362
356
363
if (pooled ) {
357
364
mongoc_client_pool_push (pool , client );
0 commit comments