@@ -79,6 +79,8 @@ func init() {
79
79
}
80
80
81
81
func main () {
82
+ klog .InitFlags (nil )
83
+ flag .Set ("logtostderr" , "true" )
82
84
flag .Parse ()
83
85
84
86
if ! * inProw && * doDriverBuild {
@@ -298,27 +300,41 @@ func handle() error {
298
300
}
299
301
}()
300
302
}
303
+
301
304
// For windows cluster, when cluster is up, all Windows nodes are tainted with NoSchedule to avoid linux pods
302
305
// being scheduled to Windows nodes. When running windows tests, we need to remove the taint.
303
306
if * platform == "windows" {
304
- nodesCmd := exec .Command ("kubectl" , "get" , "nodes" , "-l" , "beta. kubernetes.io/os=windows" , "-o" , "name" )
307
+ nodesCmd := exec .Command ("kubectl" , "get" , "nodes" , "-l" , "kubernetes.io/os=windows" , "-o" , "name" )
305
308
out , err := nodesCmd .CombinedOutput ()
306
309
if err != nil {
307
- return fmt .Errorf ("failed to get nodes: %v" , err )
310
+ return fmt .Errorf ("failed to get windows nodes: %v" , err )
308
311
}
309
312
nodes := strings .Fields (string (out ))
310
313
for _ , node := range nodes {
311
314
taintCmd := exec .Command ("kubectl" , "taint" , "node" , node , "node.kubernetes.io/os:NoSchedule-" )
312
- _ , err = taintCmd .CombinedOutput ()
315
+ out , err : = taintCmd .CombinedOutput ()
313
316
if err != nil {
314
317
return fmt .Errorf ("failed to untaint windows node %v" , err )
315
318
}
319
+ klog .Infof ("untaint windows nodes: %s, output %s" , node , string (out ))
320
+ }
321
+
322
+ // It typically takes 5+ minutes to download Windows container image. To avoid tests being timed out,
323
+ // pre-pulling the test images as best effort.
324
+ klog .Infof ("Prepulling test images." )
325
+ err = os .Setenv ("PREPULL_IMAGE" , filepath .Join (pkgDir , "test" , "k8s-integration" , "prepull.yaml" ))
326
+ if err != nil {
327
+ return err
328
+ }
329
+ out , err = exec .Command (filepath .Join (pkgDir , "test" , "k8s-integration" , "prepull-image.sh" )).CombinedOutput ()
330
+ if err != nil {
331
+ return fmt .Errorf ("failed to prepull images: %s, err: %v" , out , err )
316
332
}
317
333
}
318
334
319
335
if ! * useGKEManagedDriver {
320
336
// Install the driver and defer its teardown
321
- err := installDriver (goPath , pkgDir , * stagingImage , stagingVersion , * deployOverlayName , * doDriverBuild )
337
+ err := installDriver (* platform , goPath , pkgDir , * stagingImage , stagingVersion , * deployOverlayName , * doDriverBuild )
322
338
if * teardownDriver {
323
339
defer func () {
324
340
if teardownErr := deleteDriver (goPath , pkgDir , * deployOverlayName ); teardownErr != nil {
@@ -342,6 +358,30 @@ func handle() error {
342
358
}()
343
359
}
344
360
361
+ // For windows cluster, it has both Windows nodes and Linux nodes. Before triggering the tests, taint Linux nodes
362
+ // with NoSchedule to avoid test pods being scheduled on Linux. Need to do this step after driver is deployed.
363
+ // Also the test framework will not proceed to run tests unless all nodes are ready
364
+ // AND schedulable. Allow not-ready nodes since we make Linux nodes
365
+ // unschedulable.
366
+ allowedNotReadyNodes := 0
367
+ if * platform == "windows" {
368
+ nodesCmd := exec .Command ("kubectl" , "get" , "nodes" , "-l" , "kubernetes.io/os=linux" , "-o" , "name" )
369
+ out , err := nodesCmd .CombinedOutput ()
370
+ if err != nil {
371
+ return fmt .Errorf ("failed to get linux nodes: %v" , err )
372
+ }
373
+ nodes := strings .Fields (string (out ))
374
+ allowedNotReadyNodes = len (nodes )
375
+ for _ , node := range nodes {
376
+ taintCmd := exec .Command ("kubectl" , "taint" , "node" , node , "node.kubernetes.io/os:NoSchedule" )
377
+ out , err := taintCmd .CombinedOutput ()
378
+ if err != nil {
379
+ return fmt .Errorf ("failed to untaint windows node %v" , err )
380
+ }
381
+ klog .Infof ("taint linux nodes: %s, output %s" , node , string (out ))
382
+ }
383
+ }
384
+
345
385
var cloudProviderArgs []string
346
386
var err error
347
387
switch * deploymentStrat {
@@ -374,7 +414,8 @@ func handle() error {
374
414
for _ , scFile := range storageClasses {
375
415
outputDir := strings .TrimSuffix (scFile , ".yaml" )
376
416
testOutputDirs = append (testOutputDirs , outputDir )
377
- if err = runCSITests (* platform , pkgDir , testDir , * testFocus , testSkip , scFile , * snapshotClassFile , cloudProviderArgs , * deploymentStrat , outputDir ); err != nil {
417
+ if err = runCSITests (* platform , pkgDir , testDir , * testFocus , testSkip , scFile ,
418
+ * snapshotClassFile , cloudProviderArgs , * deploymentStrat , outputDir , allowedNotReadyNodes ); err != nil {
378
419
ginkgoErrors = append (ginkgoErrors , err .Error ())
379
420
}
380
421
}
@@ -455,19 +496,20 @@ func setEnvProject(project string) error {
455
496
}
456
497
457
498
func runMigrationTests (pkgDir , testDir , testFocus , testSkip string , cloudProviderArgs []string ) error {
458
- return runTestsWithConfig (testDir , testFocus , testSkip , "--storage.migratedPlugins=kubernetes.io/gce-pd" , cloudProviderArgs , "" )
499
+ return runTestsWithConfig (testDir , testFocus , testSkip , "--storage.migratedPlugins=kubernetes.io/gce-pd" , cloudProviderArgs , "" , 0 )
459
500
}
460
501
461
- func runCSITests (platform , pkgDir , testDir , testFocus , testSkip , storageClassFile , snapshotClassFile string , cloudProviderArgs []string , deploymentStrat , reportPrefix string ) error {
502
+ func runCSITests (platform , pkgDir , testDir , testFocus , testSkip , storageClassFile , snapshotClassFile string ,
503
+ cloudProviderArgs []string , deploymentStrat , reportPrefix string , allowedNotReadyNodes int ) error {
462
504
testDriverConfigFile , err := generateDriverConfigFile (platform , pkgDir , storageClassFile , snapshotClassFile , deploymentStrat )
463
505
if err != nil {
464
506
return err
465
507
}
466
508
testConfigArg := fmt .Sprintf ("--storage.testdriver=%s" , testDriverConfigFile )
467
- return runTestsWithConfig (testDir , testFocus , testSkip , testConfigArg , cloudProviderArgs , reportPrefix )
509
+ return runTestsWithConfig (testDir , testFocus , testSkip , testConfigArg , cloudProviderArgs , reportPrefix , allowedNotReadyNodes )
468
510
}
469
511
470
- func runTestsWithConfig (testDir , testFocus , testSkip , testConfigArg string , cloudProviderArgs []string , reportPrefix string ) error {
512
+ func runTestsWithConfig (testDir , testFocus , testSkip , testConfigArg string , cloudProviderArgs []string , reportPrefix string , allowedNotReadyNodes int ) error {
471
513
err := os .Chdir (testDir )
472
514
if err != nil {
473
515
return err
@@ -494,7 +536,7 @@ func runTestsWithConfig(testDir, testFocus, testSkip, testConfigArg string, clou
494
536
}
495
537
ginkgoArgs := fmt .Sprintf ("--ginkgo.focus=%s --ginkgo.skip=%s" , testFocus , testSkip )
496
538
if * platform == "windows" {
497
- ginkgoArgs = ginkgoArgs + fmt .Sprintf (" --node-os-distro=%s" , * platform )
539
+ ginkgoArgs = ginkgoArgs + fmt .Sprintf (" --node-os-distro=%s --allowed-not-ready-nodes=%d " , * platform , allowedNotReadyNodes )
498
540
}
499
541
testArgs := fmt .Sprintf ("%s %s %s" ,
500
542
ginkgoArgs ,
0 commit comments