@@ -975,13 +975,14 @@ def test_handle_execute_response_sets_active_op_handle(self):
975
975
def test_make_request_will_retry_GetOperationStatus (
976
976
self , mock_retry_policy , mock_GetOperationStatus , t_transport_class ):
977
977
978
- import thrift
978
+ import thrift , errno
979
979
from databricks .sql .thrift_api .TCLIService .TCLIService import Client
980
980
from databricks .sql .exc import RequestError
981
981
from databricks .sql .utils import NoRetryReason
982
982
983
- mock_GetOperationStatus .__name__ = "GetOperationStatus"
984
- mock_GetOperationStatus .side_effect = TimeoutError (110 )
983
+ this_gos_name = "GetOperationStatus"
984
+ mock_GetOperationStatus .__name__ = this_gos_name
985
+ mock_GetOperationStatus .side_effect = OSError (errno .ETIMEDOUT , "Connection timed out" )
985
986
986
987
protocol = thrift .protocol .TBinaryProtocol .TBinaryProtocol (t_transport_class )
987
988
client = Client (protocol )
@@ -998,13 +999,30 @@ def test_make_request_will_retry_GetOperationStatus(
998
999
443 ,
999
1000
"path" , [],
1000
1001
_retry_stop_after_attempts_count = EXPECTED_RETRIES ,
1001
- _retry_delay_default = 0.1 )
1002
+ _retry_delay_default = 1 )
1003
+
1002
1004
1003
1005
with self .assertRaises (RequestError ) as cm :
1004
1006
thrift_backend .make_request (client .GetOperationStatus , req )
1005
1007
1006
1008
self .assertEqual (NoRetryReason .OUT_OF_ATTEMPTS .value , cm .exception .context ["no-retry-reason" ])
1007
- self .assertEqual (f'{ EXPECTED_RETRIES } /{ EXPECTED_RETRIES } ' , cm .exception .context ["attempt" ])
1009
+ self .assertEqual (f'{ EXPECTED_RETRIES } /{ EXPECTED_RETRIES } ' , cm .exception .context ["attempt" ])
1010
+
1011
+ # Unusual OSError code
1012
+ mock_GetOperationStatus .side_effect = OSError (errno .EEXIST , "File does not exist" )
1013
+
1014
+ with self .assertLogs ("databricks.sql.thrift_backend" , level = logging .WARNING ) as cm :
1015
+ with self .assertRaises (RequestError ):
1016
+ thrift_backend .make_request (client .GetOperationStatus , req )
1017
+
1018
+ # There should be two warning log messages: one for each retry
1019
+ self .assertEqual (len (cm .output ), EXPECTED_RETRIES )
1020
+
1021
+ # The warnings should be identical
1022
+ self .assertEqual (cm .output [1 ], cm .output [0 ])
1023
+
1024
+ # The warnings should include this text
1025
+ self .assertIn (f"{ this_gos_name } failed with code { errno .EEXIST } and will attempt to retry" , cm .output [0 ])
1008
1026
1009
1027
1010
1028
@patch ("thrift.transport.THttpClient.THttpClient" )
0 commit comments