@@ -95,7 +95,7 @@ stringData:
95
95
})
96
96
97
97
logger .Section ("check App uses new secret" , func () {
98
- retry (t , 10 * time . Second , func () error {
98
+ retry (t , 10 , func () error {
99
99
out := kubectl .Run ([]string {"get" , "configmap/configmap" , "-o" , "yaml" })
100
100
101
101
var cm corev1.ConfigMap
@@ -193,7 +193,7 @@ data:
193
193
})
194
194
195
195
logger .Section ("check App uses new configmap" , func () {
196
- retry (t , 10 * time . Second , func () error {
196
+ retry (t , 10 , func () error {
197
197
out := kubectl .Run ([]string {"get" , "configmap/configmap" , "-o" , "yaml" })
198
198
199
199
var cm corev1.ConfigMap
@@ -210,17 +210,14 @@ data:
210
210
})
211
211
}
212
212
213
- func retry (t * testing.T , timeout time. Duration , f func () error ) {
213
+ func retry (t * testing.T , maxRetries int , f func () error ) {
214
214
var err error
215
- stopTime := time .Now ().Add (timeout )
216
- for {
215
+ for i := 0 ; i < maxRetries ; i ++ {
217
216
err = f ()
218
217
if err == nil {
219
218
return
220
219
}
221
- if time .Now ().After (stopTime ) {
222
- t .Fatalf ("retry timed out after %s: %v" , timeout .String (), err )
223
- }
224
220
time .Sleep (1 * time .Second )
225
221
}
222
+ t .Fatalf ("retry failed after %d attempts: %v" , maxRetries , err )
226
223
}
0 commit comments