@@ -158,7 +158,12 @@ func TestVolumeDrain_Downscale(t *testing.T) {
158
158
}))
159
159
160
160
require .Eventually (t , func () bool {
161
- rawOut , err := exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "logs" , consumer .PodKey .Name ).Output ()
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
166
+ rawOut , err := cmd .Output ()
162
167
if err != nil {
163
168
t .Logf ("failed to get log consumer logs: %v" , err )
164
169
return false
@@ -167,10 +172,20 @@ func TestVolumeDrain_Downscale(t *testing.T) {
167
172
return strings .Contains (string (rawOut ), "got request" )
168
173
}, 5 * time .Minute , 2 * time .Second )
169
174
170
- require .NoError (t , exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" ).Run ())
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
180
+ require .NoError (t , cmd .Run ())
171
181
172
182
require .Eventually (t , func () bool {
173
- rawOut , err := exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" ).Output ()
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
188
+ rawOut , err := cmd .Output ()
174
189
if err != nil {
175
190
t .Logf ("failed to list buffer directory: %v" , err )
176
191
return false
@@ -191,7 +206,12 @@ func TestVolumeDrain_Downscale(t *testing.T) {
191
206
192
207
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 30 * time .Second , time .Second / 2 )
193
208
194
- require .NoError (t , exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" ).Run ())
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
214
+ require .NoError (t , cmd .Run ())
195
215
196
216
require .Eventually (t , cond .ResourceShouldBeAbsent (t , c .GetClient (), common .Resource (new (batchv1.Job ), ns , drainerJobName )), 5 * time .Minute , 30 * time .Second )
197
217
@@ -319,7 +339,12 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
319
339
}))
320
340
321
341
require .Eventually (t , func () bool {
322
- rawOut , err := exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "logs" , consumer .PodKey .Name ).Output ()
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
347
+ rawOut , err := cmd .Output ()
323
348
if err != nil {
324
349
t .Logf ("failed to get log consumer logs: %v" , err )
325
350
return false
@@ -328,10 +353,20 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
328
353
return strings .Contains (string (rawOut ), "got request" )
329
354
}, 5 * time .Minute , 2 * time .Second )
330
355
331
- require .NoError (t , exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/off" ).Run ())
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
361
+ require .NoError (t , cmd .Run ())
332
362
333
363
require .Eventually (t , func () bool {
334
- rawOut , err := exec .Command ("kubectl" , "-n" , ns , "exec" , fluentdReplicaName , "-c" , "fluentd" , "--" , "ls" , "-1" , "/buffers" ).Output ()
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
369
+ rawOut , err := cmd .Output ()
335
370
if err != nil {
336
371
t .Logf ("failed to list buffer directory: %v" , err )
337
372
return false
@@ -352,7 +387,12 @@ func TestVolumeDrain_Downscale_DeleteVolume(t *testing.T) {
352
387
353
388
require .Eventually (t , cond .PodShouldBeRunning (t , c .GetClient (), client.ObjectKey {Namespace : ns , Name : fluentdReplicaName }), 30 * time .Second , time .Second / 2 )
354
389
355
- require .NoError (t , exec .Command ("kubectl" , "-n" , consumer .PodKey .Namespace , "exec" , consumer .PodKey .Name , "--" , "curl" , "-sS" , "http://localhost:8082/on" ).Run ())
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
395
+ require .NoError (t , cmd .Run ())
356
396
357
397
require .Eventually (t , cond .ResourceShouldBeAbsent (t , c .GetClient (), common .Resource (new (batchv1.Job ), ns , drainerJobName )), 5 * time .Minute , 30 * time .Second )
358
398
0 commit comments