@@ -109,7 +109,7 @@ func TestVolumeDrain_Downscale(t *testing.T) {
109
109
},
110
110
},
111
111
}
112
- require . NoError (t , c .GetClient ().Create (ctx , & logging ))
112
+ common . RequireNoError (t , c .GetClient ().Create (ctx , & logging ))
113
113
tags := "time"
114
114
output := v1beta1.Output {
115
115
ObjectMeta : metav1.ObjectMeta {
@@ -128,7 +128,7 @@ func TestVolumeDrain_Downscale(t *testing.T) {
128
128
},
129
129
},
130
130
}
131
- require . NoError (t , c .GetClient ().Create (ctx , & output ))
131
+ common . RequireNoError (t , c .GetClient ().Create (ctx , & output ))
132
132
flow := v1beta1.Flow {
133
133
ObjectMeta : metav1.ObjectMeta {
134
134
Name : "test-flow" ,
@@ -147,7 +147,7 @@ func TestVolumeDrain_Downscale(t *testing.T) {
147
147
LocalOutputRefs : []string {output .Name },
148
148
},
149
149
}
150
- require . NoError (t , c .GetClient ().Create (ctx , & flow ))
150
+ common . RequireNoError (t , c .GetClient ().Create (ctx , & flow ))
151
151
152
152
fluentdReplicaName := logging .Name + "-fluentd-1"
153
153
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 5 * time .Minute , 5 * time .Second )
@@ -169,7 +169,7 @@ func TestVolumeDrain_Downscale(t *testing.T) {
169
169
}, 5 * time .Minute , 2 * time .Second )
170
170
171
171
cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" ), c )
172
- require . NoError (t , cmd .Run ())
172
+ common . RequireNoError (t , cmd .Run ())
173
173
174
174
require .Eventually (t , func () bool {
175
175
cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" ), c )
@@ -183,7 +183,7 @@ func TestVolumeDrain_Downscale(t *testing.T) {
183
183
184
184
patch := client .MergeFrom (logging .DeepCopy ())
185
185
logging .Spec .FluentdSpec .Scaling .Replicas = 1
186
- require . NoError (t , c .GetClient ().Patch (ctx , & logging , patch ))
186
+ common . RequireNoError (t , c .GetClient ().Patch (ctx , & logging , patch ))
187
187
188
188
drainerJobName := fluentdReplicaName + "-drainer"
189
189
require .Eventually (t , func () bool {
@@ -195,14 +195,14 @@ func TestVolumeDrain_Downscale(t *testing.T) {
195
195
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 30 * time .Second , time .Second / 2 )
196
196
197
197
cmd = common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" ), c )
198
- require . NoError (t , cmd .Run ())
198
+ common . RequireNoError (t , cmd .Run ())
199
199
200
200
require .Eventually (t , cond .ResourceShouldBeAbsent (t , c .GetClient (), common .Resource (new (batchv1.Job ), ns , drainerJobName )), 5 * time .Minute , 30 * time .Second )
201
201
202
202
require .Eventually (t , cond .ResourceShouldBeAbsent (t , c .GetClient (), common .Resource (new (corev1.Pod ), ns , fluentdReplicaName )), 30 * time .Second , time .Second / 2 )
203
203
204
204
pvc := common .Resource (new (corev1.PersistentVolumeClaim ), ns , logging .Name + "-fluentd-buffer-" + fluentdReplicaName )
205
- require . NoError (t , c .GetClient ().Get (ctx , client .ObjectKeyFromObject (pvc ), pvc ))
205
+ common . RequireNoError (t , c .GetClient ().Get (ctx , client .ObjectKeyFromObject (pvc ), pvc ))
206
206
assert .Equal (t , "drained" , pvc .GetLabels ()["logging.banzaicloud.io/drain-status" ])
207
207
}, func (t * testing.T , c common.Cluster ) error {
208
208
path := filepath .Join (TestTempDir , fmt .Sprintf ("cluster-%s.log" , t .Name ()))
@@ -216,12 +216,12 @@ func TestVolumeDrain_Downscale(t *testing.T) {
216
216
if o .Scheme == nil {
217
217
o .Scheme = runtime .NewScheme ()
218
218
}
219
- require . NoError (t , v1beta1 .AddToScheme (o .Scheme ))
220
- require . NoError (t , apiextensionsv1 .AddToScheme (o .Scheme ))
221
- require . NoError (t , appsv1 .AddToScheme (o .Scheme ))
222
- require . NoError (t , batchv1 .AddToScheme (o .Scheme ))
223
- require . NoError (t , corev1 .AddToScheme (o .Scheme ))
224
- require . NoError (t , rbacv1 .AddToScheme (o .Scheme ))
219
+ common . RequireNoError (t , v1beta1 .AddToScheme (o .Scheme ))
220
+ common . RequireNoError (t , apiextensionsv1 .AddToScheme (o .Scheme ))
221
+ common . RequireNoError (t , appsv1 .AddToScheme (o .Scheme ))
222
+ common . RequireNoError (t , batchv1 .AddToScheme (o .Scheme ))
223
+ common . RequireNoError (t , corev1 .AddToScheme (o .Scheme ))
224
+ common . RequireNoError (t , rbacv1 .AddToScheme (o .Scheme ))
225
225
})
226
226
}
227
227
@@ -274,7 +274,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
274
274
},
275
275
},
276
276
}
277
- require . NoError (t , c .GetClient ().Create (ctx , & logging ))
277
+ common . RequireNoError (t , c .GetClient ().Create (ctx , & logging ))
278
278
tags := "time"
279
279
output := v1beta1.Output {
280
280
ObjectMeta : metav1.ObjectMeta {
@@ -293,7 +293,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
293
293
},
294
294
},
295
295
}
296
- require . NoError (t , c .GetClient ().Create (ctx , & output ))
296
+ common . RequireNoError (t , c .GetClient ().Create (ctx , & output ))
297
297
flow := v1beta1.Flow {
298
298
ObjectMeta : metav1.ObjectMeta {
299
299
Name : "test-flow" ,
@@ -312,7 +312,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
312
312
LocalOutputRefs : []string {output .Name },
313
313
},
314
314
}
315
- require . NoError (t , c .GetClient ().Create (ctx , & flow ))
315
+ common . RequireNoError (t , c .GetClient ().Create (ctx , & flow ))
316
316
317
317
fluentdReplicaName := logging .Name + "-fluentd-1"
318
318
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 2 * time .Minute , 5 * time .Second )
@@ -334,7 +334,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
334
334
}, 5 * time .Minute , 2 * time .Second )
335
335
336
336
cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" ), c )
337
- require . NoError (t , cmd .Run ())
337
+ common . RequireNoError (t , cmd .Run ())
338
338
339
339
require .Eventually (t , func () bool {
340
340
cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" ), c )
@@ -348,7 +348,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
348
348
349
349
patch := client .MergeFrom (logging .DeepCopy ())
350
350
logging .Spec .FluentdSpec .Scaling .Replicas = 1
351
- require . NoError (t , c .GetClient ().Patch (ctx , & logging , patch ))
351
+ common . RequireNoError (t , c .GetClient ().Patch (ctx , & logging , patch ))
352
352
353
353
drainerJobName := fluentdReplicaName + "-drainer"
354
354
require .Eventually (t , func () bool {
@@ -360,7 +360,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
360
360
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 30 * time .Second , time .Second / 2 )
361
361
362
362
cmd = common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" ), c )
363
- require . NoError (t , cmd .Run ())
363
+ common . RequireNoError (t , cmd .Run ())
364
364
365
365
require .Eventually (t , cond .ResourceShouldBeAbsent (t , c .GetClient (), common .Resource (new (batchv1.Job ), ns , drainerJobName )), 5 * time .Minute , 30 * time .Second )
366
366
@@ -379,11 +379,11 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
379
379
if o .Scheme == nil {
380
380
o .Scheme = runtime .NewScheme ()
381
381
}
382
- require . NoError (t , v1beta1 .AddToScheme (o .Scheme ))
383
- require . NoError (t , apiextensionsv1 .AddToScheme (o .Scheme ))
384
- require . NoError (t , appsv1 .AddToScheme (o .Scheme ))
385
- require . NoError (t , batchv1 .AddToScheme (o .Scheme ))
386
- require . NoError (t , corev1 .AddToScheme (o .Scheme ))
387
- require . NoError (t , rbacv1 .AddToScheme (o .Scheme ))
382
+ common . RequireNoError (t , v1beta1 .AddToScheme (o .Scheme ))
383
+ common . RequireNoError (t , apiextensionsv1 .AddToScheme (o .Scheme ))
384
+ common . RequireNoError (t , appsv1 .AddToScheme (o .Scheme ))
385
+ common . RequireNoError (t , batchv1 .AddToScheme (o .Scheme ))
386
+ common . RequireNoError (t , corev1 .AddToScheme (o .Scheme ))
387
+ common . RequireNoError (t , rbacv1 .AddToScheme (o .Scheme ))
388
388
})
389
389
}
0 commit comments