@@ -929,7 +929,7 @@ def raise_error(target_node, *args, **kwargs):
929
929
rc = get_mocked_redis_client (
930
930
host = default_host ,
931
931
port = default_port ,
932
- retry = Retry (ConstantBackoff (1 ), 3 ),
932
+ retry = Retry (ConstantBackoff (1 ), 10 ),
933
933
)
934
934
935
935
with pytest .raises (error ):
@@ -3091,6 +3091,33 @@ def test_empty_stack(self, r):
3091
3091
result = p .execute ()
3092
3092
assert result == []
3093
3093
3094
+ @pytest .mark .parametrize ("error" , [ConnectionError , TimeoutError ])
3095
+ def test_additional_backoff_cluster_pipeline (self , r , error ):
3096
+ with patch .object (ConstantBackoff , "compute" ) as compute :
3097
+
3098
+ def _compute (target_node , * args , ** kwargs ):
3099
+ return 1
3100
+
3101
+ compute .side_effect = _compute
3102
+ with patch ("redis.cluster.get_connection" ) as get_connection :
3103
+
3104
+ def raise_error (target_node , * args , ** kwargs ):
3105
+ get_connection .failed_calls += 1
3106
+ raise error ("mocked error" )
3107
+
3108
+ get_connection .side_effect = raise_error
3109
+
3110
+ r .set_retry (Retry (ConstantBackoff (1 ), 10 ))
3111
+ pipeline = r .pipeline ()
3112
+
3113
+ with pytest .raises (error ):
3114
+ pipeline .get ("bar" )
3115
+ pipeline .get ("bar" )
3116
+ pipeline .execute ()
3117
+ # cluster pipeline does one more back off than a single Redis command
3118
+ # this is not required, but it's just how it's implemented as of now
3119
+ assert compute .call_count == r .cluster_error_retry_attempts + 1
3120
+
3094
3121
3095
3122
@pytest .mark .onlycluster
3096
3123
class TestReadOnlyPipeline :
0 commit comments