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
@@ -482,7 +483,6 @@ test_mongoc_uri_functions (void)
482
483
uri = mongoc_uri_new ("mongodb://localhost/?serverselectiontimeoutms=3"
483
484
"&journal=true"
484
485
"&wtimeoutms=42"
485
- "&localthresholdms=17"
486
486
"&canonicalizeHostname=false" );
487
487
488
488
ASSERT_CMPINT (
@@ -502,12 +502,6 @@ test_mongoc_uri_functions (void)
502
502
ASSERT_CMPINT (
503
503
mongoc_uri_get_option_as_int32 (uri , "wtimeoutms" , 19 ), = = , 18 );
504
504
505
- ASSERT_CMPINT (
506
- mongoc_uri_get_option_as_int32 (uri , "localthresholdms" , 99 ), = = , 17 );
507
- ASSERT (mongoc_uri_set_option_as_int32 (uri , "localthresholdms" , 99 ));
508
- ASSERT_CMPINT (
509
- mongoc_uri_get_option_as_int32 (uri , "localthresholdms" , 42 ), = = , 99 );
510
-
511
505
/* socketcheckintervalms isn't set, return our fallback */
512
506
ASSERT_CMPINT (
513
507
mongoc_uri_get_option_as_int32 (uri , "socketcheckintervalms" , 123 ),
@@ -1070,6 +1064,33 @@ test_mongoc_uri_long_hostname (void)
1070
1064
bson_free (host );
1071
1065
}
1072
1066
1067
+ test_mongoc_uri_local_threshold_ms (void )
1068
+ {
1069
+ mongoc_uri_t * uri ;
1070
+
1071
+ uri = mongoc_uri_new ("mongodb://localhost/" );
1072
+
1073
+ /* localthresholdms isn't set, return the default */
1074
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = ,
1075
+ MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS );
1076
+ ASSERT (
1077
+ mongoc_uri_set_option_as_int32 (uri , "localthresholdms" , 99 ));
1078
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = , 99 );
1079
+
1080
+ mongoc_uri_destroy (uri );
1081
+
1082
+
1083
+ uri = mongoc_uri_new (
1084
+ "mongodb://localhost/?localthresholdms=0" );
1085
+
1086
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = , 0 );
1087
+ ASSERT (
1088
+ mongoc_uri_set_option_as_int32 (uri , "localthresholdms" , 99 ));
1089
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = , 99 );
1090
+
1091
+ mongoc_uri_destroy (uri );
1092
+ }
1093
+
1073
1094
void
1074
1095
test_uri_install (TestSuite * suite )
1075
1096
{
@@ -1089,4 +1110,5 @@ test_uri_install (TestSuite *suite)
1089
1110
TestSuite_Add (
1090
1111
suite , "/Uri/compound_setters" , test_mongoc_uri_compound_setters );
1091
1112
TestSuite_Add (suite , "/Uri/long_hostname" , test_mongoc_uri_long_hostname );
1113
+ TestSuite_Add (suite , "/Uri/local_threshold_ms" , test_mongoc_uri_local_threshold_ms );
1092
1114
}
0 commit comments