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):
95
95
def _fail (self , error ):
96
96
self .actual_failures += 1
97
97
98
+ def _fail_inf (self , error ):
99
+ self .actual_failures += 1
100
+ if self .actual_failures == 5 :
101
+ raise ConnectionError ()
102
+
98
103
@pytest .mark .parametrize ("retries" , range (10 ))
99
104
def test_retry (self , retries ):
100
105
backoff = BackoffMock ()
@@ -107,6 +112,16 @@ def test_retry(self, retries):
107
112
assert backoff .reset_calls == 1
108
113
assert backoff .calls == retries
109
114
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
+
110
125
111
126
@pytest .mark .onlynoncluster
112
127
class TestRedisClientRetry :
You can’t perform that action at this time.
0 commit comments