File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,11 @@ def _do(self):
9595 def  _fail (self , error ):
9696 self .actual_failures  +=  1 
9797
98+  def  _fail_inf (self , error ):
99+  self .actual_failures  +=  1 
100+  if  self .actual_failures  ==  5 :
101+  raise  ConnectionError ()
102+ 
98103 @pytest .mark .parametrize ("retries" , range (10 )) 
99104 def  test_retry (self , retries ):
100105 backoff  =  BackoffMock ()
@@ -107,6 +112,16 @@ def test_retry(self, retries):
107112 assert  backoff .reset_calls  ==  1 
108113 assert  backoff .calls  ==  retries 
109114
115+  def  test_infinite_retry (self ):
116+  backoff  =  BackoffMock ()
117+  # specify infinite retries, but give up after 5 
118+  retry  =  Retry (backoff , - 1 )
119+  with  pytest .raises (ConnectionError ):
120+  retry .call_with_retry (self ._do , self ._fail_inf )
121+ 
122+  assert  self .actual_attempts  ==  5 
123+  assert  self .actual_failures  ==  5 
124+ 
110125
111126@pytest .mark .onlynoncluster  
112127class  TestRedisClientRetry :
                         You can’t perform that action at this time. 
           
                  
0 commit comments