@@ -416,7 +416,8 @@ def find_one():
416
416
@client_context .require_failCommand_fail_point
417
417
def test_csot_timeout_message (self ):
418
418
client = rs_or_single_client (appName = "connectionTimeoutApp" )
419
- # Mock a connection failing due to timeout.
419
+ self .addCleanup (client .close )
420
+ # Mock an operation failing due to pymongo.timeout().
420
421
mock_connection_timeout = {
421
422
"configureFailPoint" : "failCommand" ,
422
423
"mode" : "alwaysOn" ,
@@ -440,8 +441,8 @@ def test_csot_timeout_message(self):
440
441
@client_context .require_failCommand_fail_point
441
442
def test_socket_timeout_message (self ):
442
443
client = rs_or_single_client (socketTimeoutMS = 500 , appName = "connectionTimeoutApp" )
443
-
444
- # Mock a connection failing due to timeout .
444
+ self . addCleanup ( client . close )
445
+ # Mock an operation failing due to socketTimeoutMS .
445
446
mock_connection_timeout = {
446
447
"configureFailPoint" : "failCommand" ,
447
448
"mode" : "alwaysOn" ,
@@ -469,7 +470,7 @@ def test_socket_timeout_message(self):
469
470
4 , 9 , 0
470
471
) # configureFailPoint does not allow failure on handshake before 4.9, fixed in SERVER-49336
471
472
def test_connection_timeout_message (self ):
472
- # Mock a connection failing due to timeout.
473
+ # Mock a connection creation failing due to timeout.
473
474
mock_connection_timeout = {
474
475
"configureFailPoint" : "failCommand" ,
475
476
"mode" : "alwaysOn" ,
@@ -481,9 +482,18 @@ def test_connection_timeout_message(self):
481
482
},
482
483
}
483
484
485
+ client = rs_or_single_client (
486
+ connectTimeoutMS = 500 ,
487
+ socketTimeoutMS = 500 ,
488
+ appName = "connectionTimeoutApp" ,
489
+ heartbeatFrequencyMS = 1000000 ,
490
+ )
491
+ self .addCleanup (client .close )
492
+ client .admin .command ("ping" )
493
+ pool = get_pool (client )
494
+ pool .reset_without_pause ()
484
495
with self .fail_point (mock_connection_timeout ):
485
496
with self .assertRaises (Exception ) as error :
486
- client = rs_or_single_client (connectTimeoutMS = 500 , appName = "connectionTimeoutApp" )
487
497
client .admin .command ("ping" )
488
498
489
499
self .assertTrue (
0 commit comments