@@ -455,6 +455,54 @@ test_mongoc_client_preselect (void)
455
455
}
456
456
457
457
458
+ static void
459
+ test_unavailable_seeds (void )
460
+ {
461
+ mongoc_client_t * client ;
462
+ mongoc_collection_t * collection ;
463
+ mongoc_cursor_t * cursor ;
464
+ bson_t query = BSON_INITIALIZER ;
465
+ const bson_t * doc ;
466
+
467
+ const char * uri_strs [] = {
468
+ "mongodb://a:1/?connectTimeoutMS=1" ,
469
+ "mongodb://a:1,a:2/?connectTimeoutMS=1" ,
470
+ "mongodb://a:1,a:2/?replicaSet=r&connectTimeoutMS=1" ,
471
+ "mongodb://u:p@a:1/?connectTimeoutMS=1" ,
472
+ "mongodb://u:p@a:1,a:2/?connectTimeoutMS=1" ,
473
+ "mongodb://u:p@a:1,a:2/?replicaSet=r&connectTimeoutMS=1" ,
474
+ };
475
+
476
+ int i ;
477
+
478
+ /* hardcode the number of error messages we have to suppress */
479
+ for (i = 0 ; i < 18 ; i ++ ) {
480
+ suppress_one_message ();
481
+ }
482
+
483
+ for (i = 0 ; i < (sizeof (uri_strs ) / sizeof (const char * )); i ++ ) {
484
+ client = mongoc_client_new (uri_strs [i ]);
485
+ assert (client );
486
+
487
+ collection = mongoc_client_get_collection (client , "test" , "test" );
488
+ cursor = mongoc_collection_find (collection ,
489
+ MONGOC_QUERY_NONE ,
490
+ 0 ,
491
+ 0 ,
492
+ 0 ,
493
+ & query ,
494
+ NULL ,
495
+ NULL );
496
+
497
+ assert (! mongoc_cursor_next (cursor , & doc ));
498
+
499
+ mongoc_cursor_destroy (cursor );
500
+ mongoc_collection_destroy (collection );
501
+ mongoc_client_destroy (client );
502
+ }
503
+ }
504
+
505
+
458
506
static void
459
507
test_exhaust_cursor (void )
460
508
{
@@ -693,6 +741,7 @@ test_client_install (TestSuite *suite)
693
741
TestSuite_Add (suite , "/Client/command" , test_mongoc_client_command );
694
742
TestSuite_Add (suite , "/Client/command_secondary" , test_mongoc_client_command_secondary );
695
743
TestSuite_Add (suite , "/Client/preselect" , test_mongoc_client_preselect );
744
+ TestSuite_Add (suite , "/Client/unavailable_seeds" , test_unavailable_seeds );
696
745
TestSuite_Add (suite , "/Client/exhaust_cursor" , test_exhaust_cursor );
697
746
TestSuite_Add (suite , "/Client/server_status" , test_server_status );
698
747
}
0 commit comments