@@ -158,11 +158,7 @@ func TestVolumeDrain_Downscale(t *testing.T) {
158
158
}))
159
159
160
160
require .Eventually (t , func () bool {
161
- cmd := exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "logs" , consumer .PodKey .Name )
162
- cmd .Env = []string {
163
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
164
- }
165
- cmd .Stderr = os .Stderr
161
+ cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "logs" , consumer .PodKey .Name ), c )
166
162
rawOut , err := cmd .Output ()
167
163
if err != nil {
168
164
t .Logf ("failed to get log consumer logs: %v" , err )
@@ -172,19 +168,11 @@ func TestVolumeDrain_Downscale(t *testing.T) {
172
168
return strings .Contains (string (rawOut ), "got request" )
173
169
}, 5 * time .Minute , 2 * time .Second )
174
170
175
- cmd := exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" )
176
- cmd .Env = []string {
177
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
178
- }
179
- cmd .Stderr = os .Stderr
171
+ cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" ), c )
180
172
require .NoError (t , cmd .Run ())
181
173
182
174
require .Eventually (t , func () bool {
183
- cmd := exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" )
184
- cmd .Env = []string {
185
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
186
- }
187
- cmd .Stderr = os .Stderr
175
+ cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" ), c )
188
176
rawOut , err := cmd .Output ()
189
177
if err != nil {
190
178
t .Logf ("failed to list buffer directory: %v" , err )
@@ -206,11 +194,7 @@ func TestVolumeDrain_Downscale(t *testing.T) {
206
194
207
195
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 30 * time .Second , time .Second / 2 )
208
196
209
- cmd = exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" )
210
- cmd .Env = []string {
211
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
212
- }
213
- cmd .Stderr = os .Stderr
197
+ cmd = common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" ), c )
214
198
require .NoError (t , cmd .Run ())
215
199
216
200
require .Eventually (t , cond .ResourceShouldBeAbsent (t , c .GetClient (), common .Resource (new (batchv1.Job ), ns , drainerJobName )), 5 * time .Minute , 30 * time .Second )
@@ -339,11 +323,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
339
323
}))
340
324
341
325
require .Eventually (t , func () bool {
342
- cmd := exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "logs" , consumer .PodKey .Name )
343
- cmd .Env = []string {
344
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
345
- }
346
- cmd .Stderr = os .Stderr
326
+ cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "logs" , consumer .PodKey .Name ), c )
347
327
rawOut , err := cmd .Output ()
348
328
if err != nil {
349
329
t .Logf ("failed to get log consumer logs: %v" , err )
@@ -353,19 +333,11 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
353
333
return strings .Contains (string (rawOut ), "got request" )
354
334
}, 5 * time .Minute , 2 * time .Second )
355
335
356
- cmd := exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" )
357
- cmd .Env = []string {
358
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
359
- }
360
- cmd .Stderr = os .Stderr
336
+ cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" ), c )
361
337
require .NoError (t , cmd .Run ())
362
338
363
339
require .Eventually (t , func () bool {
364
- cmd := exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" )
365
- cmd .Env = []string {
366
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
367
- }
368
- cmd .Stderr = os .Stderr
340
+ cmd := common .CmdEnv (exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" ), c )
369
341
rawOut , err := cmd .Output ()
370
342
if err != nil {
371
343
t .Logf ("failed to list buffer directory: %v" , err )
@@ -387,11 +359,7 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
387
359
388
360
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 30 * time .Second , time .Second / 2 )
389
361
390
- cmd = exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" )
391
- cmd .Env = []string {
392
- fmt .Sprintf ("KUBECONFIG=%s" , c .KubeConfigFilePath ()),
393
- }
394
- cmd .Stderr = os .Stderr
362
+ cmd = common .CmdEnv (exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" ), c )
395
363
require .NoError (t , cmd .Run ())
396
364
397
365
require .Eventually (t , cond .ResourceShouldBeAbsent (t , c .GetClient (), common .Resource (new (batchv1.Job ), ns , drainerJobName )), 5 * time .Minute , 30 * time .Second )
0 commit comments