10
10
#include "mock_server/mock-server.h"
11
11
#include "mock_server/future.h"
12
12
#include "mock_server/future-functions.h"
13
+ #include "test-conveniences.h"
13
14
14
15
#undef MONGOC_LOG_DOMAIN
15
16
#define MONGOC_LOG_DOMAIN "topology-test"
@@ -725,6 +726,37 @@ test_connect_timeout_try_once_false(void)
725
726
}
726
727
727
728
729
+ static void
730
+ test_multiple_selection_errors (void )
731
+ {
732
+ const char * uri = "mongodb://doesntexist,example.com:2/?replicaSet=rs"
733
+ "&connectTimeoutMS=100" ;
734
+ mongoc_client_t * client ;
735
+ bson_t reply ;
736
+ bson_error_t error ;
737
+
738
+ client = mongoc_client_new (uri );
739
+ mongoc_client_command_simple (client , "test" , tmp_bson ("{'ping': 1}" ),
740
+ NULL , & reply , & error );
741
+
742
+ ASSERT_CMPINT (MONGOC_ERROR_SERVER_SELECTION , = = , error .domain );
743
+ ASSERT_CMPINT (MONGOC_ERROR_SERVER_SELECTION_FAILURE , = = , error .code );
744
+
745
+ /* Like:
746
+ * "No suitable servers found (`serverselectiontryonce` set):
747
+ * [Failed to resolve 'doesntexist'] [connection error]"
748
+ */
749
+ ASSERT_CONTAINS (error .message ,
750
+ "No suitable servers found" );
751
+ ASSERT_CONTAINS (error .message ,
752
+ "[connection error calling ismaster on 'example.com:2']" );
753
+ ASSERT_CONTAINS (error .message ,
754
+ "[Failed to resolve 'doesntexist']" );
755
+
756
+ mongoc_client_destroy (client );
757
+ }
758
+
759
+
728
760
void
729
761
test_topology_install (TestSuite * suite )
730
762
{
@@ -741,4 +773,5 @@ test_topology_install (TestSuite *suite)
741
773
TestSuite_Add (suite , "/Topology/connect_timeout/pooled" , test_connect_timeout_pooled );
742
774
TestSuite_Add (suite , "/Topology/connect_timeout/single/try_once" , test_connect_timeout_single );
743
775
TestSuite_Add (suite , "/Topology/connect_timeout/single/try_once_false" , test_connect_timeout_try_once_false );
776
+ TestSuite_Add (suite , "/Topology/multiple_selection_errors" , test_multiple_selection_errors );
744
777
}
0 commit comments