@@ -572,6 +572,8 @@ test_seed_list (bool rs,
572
572
mongoc_topology_description_t * td ;
573
573
mongoc_read_prefs_t * primary_pref ;
574
574
uint32_t discovered_nodes_len ;
575
+ int64_t start ;
576
+ int64_t duration_usec ;
575
577
bson_t reply ;
576
578
bson_error_t error ;
577
579
uint32_t id ;
@@ -594,11 +596,11 @@ test_seed_list (bool rs,
594
596
uri = mongoc_uri_new (uri_str );
595
597
assert (uri );
596
598
597
- /* TODO: CDRIVER-798 this shouldn't be needed in order to fail promptly
598
- * in single-threaded case. */
599
- /* must be >= minHeartbeatFrequencyMS=500 or the "reconnect"
600
- * case won't have time to succeed */
601
- mongoc_uri_set_option_as_int32 ( uri , "serverSelectionTimeoutMS" , 1000 );
599
+ if ( pooled ) {
600
+ /* must be >= minHeartbeatFrequencyMS=500 or the "reconnect"
601
+ * case won't have time to succeed */
602
+ mongoc_uri_set_option_as_int32 ( uri , "serverSelectionTimeoutMS" , 1000 );
603
+ }
602
604
603
605
if (rs ) {
604
606
mock_server_auto_ismaster (server ,
@@ -637,12 +639,18 @@ test_seed_list (bool rs,
637
639
primary_pref = mongoc_read_prefs_new (MONGOC_READ_PRIMARY );
638
640
639
641
if (connection_option == CONNECT || connection_option == RECONNECT ) {
642
+ start = bson_get_monotonic_time ();
643
+
640
644
/* only localhost:port responds to initial discovery. the other seeds are
641
645
* discarded from replica set topology, but remain for sharded. */
642
646
ASSERT_OR_PRINT (mongoc_client_command_simple (
643
647
client , "test" , tmp_bson ("{'foo': 1}" ),
644
648
primary_pref , & reply , & error ), error );
645
649
650
+ /* discovery should be quick despite down servers, say < 100ms */
651
+ duration_usec = bson_get_monotonic_time () - start ;
652
+ ASSERT_CMPINT ((int ) (duration_usec / 1000 ), < , 100 );
653
+
646
654
bson_destroy (& reply );
647
655
648
656
ASSERT_CMPINT (discovered_nodes_len , = = , (int ) td -> servers -> items_len );
@@ -675,6 +683,12 @@ test_seed_list (bool rs,
675
683
client , "test" , tmp_bson ("{'foo': 1}" ),
676
684
primary_pref , & reply , & error ), error );
677
685
686
+ /* client waited for min heartbeat to pass before reconnecting, then
687
+ * reconnected quickly despite down servers, say < 100ms later */
688
+ duration_usec = bson_get_monotonic_time () - start ;
689
+ ASSERT_CMPINT ((int ) (duration_usec / 1000 ), < ,
690
+ MONGOC_TOPOLOGY_MIN_HEARTBEAT_FREQUENCY_MS + 100 );
691
+
678
692
bson_destroy (& reply );
679
693
680
694
ASSERT_CMPINT (discovered_nodes_len , = = , (int ) td -> servers -> items_len );
0 commit comments