1
1
#include <mongoc.h>
2
2
3
3
#include "mongoc-client-private.h"
4
+ #include "mongoc-topology-private.h"
4
5
#include "mongoc-uri-private.h"
5
6
#include "mongoc-host-list-private.h"
6
7
@@ -415,7 +416,6 @@ test_mongoc_uri_functions (void)
415
416
uri = mongoc_uri_new ("mongodb://localhost/?serverselectiontimeoutms=3"
416
417
"&journal=true"
417
418
"&wtimeoutms=42"
418
- "&localthresholdms=17"
419
419
"&canonicalizeHostname=false" );
420
420
421
421
ASSERT_CMPINT (mongoc_uri_get_option_as_int32 (uri , "serverselectiontimeoutms" , 18 ), = = , 3 );
@@ -426,10 +426,6 @@ test_mongoc_uri_functions (void)
426
426
ASSERT (mongoc_uri_set_option_as_int32 (uri , "wtimeoutms" , 18 ));
427
427
ASSERT_CMPINT (mongoc_uri_get_option_as_int32 (uri , "wtimeoutms" , 19 ), = = , 18 );
428
428
429
- ASSERT_CMPINT (mongoc_uri_get_option_as_int32 (uri , "localthresholdms" , 99 ), = = , 17 );
430
- ASSERT (mongoc_uri_set_option_as_int32 (uri , "localthresholdms" , 99 ));
431
- ASSERT_CMPINT (mongoc_uri_get_option_as_int32 (uri , "localthresholdms" , 42 ), = = , 99 );
432
-
433
429
/* socketcheckintervalms isn't set, return our fallback */
434
430
ASSERT_CMPINT (mongoc_uri_get_option_as_int32 (uri , "socketcheckintervalms" , 123 ), = = , 123 );
435
431
ASSERT (mongoc_uri_set_option_as_int32 (uri , "socketcheckintervalms" , 18 ));
@@ -833,6 +829,7 @@ test_mongoc_uri_read_concern (void)
833
829
mongoc_uri_destroy (uri );
834
830
}
835
831
832
+
836
833
static void
837
834
test_mongoc_uri_long_hostname (void )
838
835
{
@@ -882,6 +879,32 @@ test_mongoc_uri_long_hostname (void)
882
879
bson_free (host_and_port );
883
880
bson_free (host );
884
881
}
882
+ test_mongoc_uri_local_threshold_ms (void )
883
+ {
884
+ mongoc_uri_t * uri ;
885
+
886
+ uri = mongoc_uri_new ("mongodb://localhost/" );
887
+
888
+ /* localthresholdms isn't set, return the default */
889
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = ,
890
+ MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS );
891
+ ASSERT (
892
+ mongoc_uri_set_option_as_int32 (uri , "localthresholdms" , 99 ));
893
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = , 99 );
894
+
895
+ mongoc_uri_destroy (uri );
896
+
897
+
898
+ uri = mongoc_uri_new ("mongodb://localhost/?localthresholdms=0" );
899
+
900
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = , 0 );
901
+ ASSERT (
902
+ mongoc_uri_set_option_as_int32 (uri , "localthresholdms" , 99 ));
903
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = , 99 );
904
+
905
+ mongoc_uri_destroy (uri );
906
+ }
907
+
885
908
886
909
void
887
910
test_uri_install (TestSuite * suite )
@@ -896,4 +919,5 @@ test_uri_install (TestSuite *suite)
896
919
TestSuite_Add (suite , "/Uri/functions" , test_mongoc_uri_functions );
897
920
TestSuite_Add (suite , "/Uri/compound_setters" , test_mongoc_uri_compound_setters );
898
921
TestSuite_Add (suite , "/Uri/long_hostname" , test_mongoc_uri_long_hostname );
922
+ TestSuite_Add (suite , "/Uri/local_threshold_ms" , test_mongoc_uri_local_threshold_ms );
899
923
}
0 commit comments