@@ -19,6 +19,7 @@ def retry_policy_factory():
19
19
"_retry_delay_max" : (float , 60 , None , None ),
20
20
"_retry_stop_after_attempts_count" : (int , 30 , None , None ),
21
21
"_retry_stop_after_attempts_duration" : (float , 900 , None , None ),
22
+ "_retry_delay_default" : (float , 5 , 1 , 60 )
22
23
}
23
24
24
25
@@ -968,6 +969,44 @@ def test_handle_execute_response_sets_active_op_handle(self):
968
969
969
970
self .assertEqual (mock_resp .operationHandle , mock_cursor .active_op_handle )
970
971
972
+ @patch ("thrift.transport.THttpClient.THttpClient" )
973
+ @patch ("databricks.sql.thrift_api.TCLIService.TCLIService.Client.GetOperationStatus" )
974
+ @patch ("databricks.sql.thrift_backend._retry_policy" , new_callable = retry_policy_factory )
975
+ def test_make_request_will_retry_GetOperationStatus (
976
+ self , mock_retry_policy , mock_GetOperationStatus , t_transport_class ):
977
+
978
+ import thrift
979
+ from databricks .sql .thrift_api .TCLIService .TCLIService import Client
980
+ from databricks .sql .exc import RequestError
981
+ from databricks .sql .utils import NoRetryReason
982
+
983
+ mock_GetOperationStatus .__name__ = "GetOperationStatus"
984
+ mock_GetOperationStatus .side_effect = TimeoutError (110 )
985
+
986
+ protocol = thrift .protocol .TBinaryProtocol .TBinaryProtocol (t_transport_class )
987
+ client = Client (protocol )
988
+
989
+ req = ttypes .TGetOperationStatusReq (
990
+ operationHandle = self .operation_handle ,
991
+ getProgressUpdate = False ,
992
+ )
993
+
994
+ EXPECTED_RETRIES = 2
995
+
996
+ thrift_backend = ThriftBackend (
997
+ "foobar" ,
998
+ 443 ,
999
+ "path" , [],
1000
+ _retry_stop_after_attempts_count = EXPECTED_RETRIES ,
1001
+ _retry_delay_default = 0.1 )
1002
+
1003
+ with self .assertRaises (RequestError ) as cm :
1004
+ thrift_backend .make_request (client .GetOperationStatus , req )
1005
+
1006
+ 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" ])
1008
+
1009
+
971
1010
@patch ("thrift.transport.THttpClient.THttpClient" )
972
1011
def test_make_request_wont_retry_if_headers_not_present (self , t_transport_class ):
973
1012
t_transport_instance = t_transport_class .return_value
0 commit comments