@@ -20,6 +20,7 @@ import (
20
20
"os"
21
21
"os/exec"
22
22
"path/filepath"
23
+ "strings"
23
24
"syscall"
24
25
25
26
"k8s.io/apimachinery/pkg/util/uuid"
33
34
teardownCluster = flag .Bool ("teardown-cluster" , true , "teardown the cluster after the e2e test" )
34
35
teardownDriver = flag .Bool ("teardown-driver" , true , "teardown the driver after the e2e test" )
35
36
bringupCluster = flag .Bool ("bringup-cluster" , true , "build kubernetes and bringup a cluster" )
37
+ platform = flag .String ("platform" , "linux" , "platform that the tests will be run, either linux or windows" )
36
38
gceZone = flag .String ("gce-zone" , "" , "zone that the gce k8s cluster is created/found in" )
37
39
gceRegion = flag .String ("gce-region" , "" , "region that gke regional cluster should be created in" )
38
40
kubeVersion = flag .String ("kube-version" , "" , "version of Kubernetes to download and use for the cluster" )
@@ -95,7 +97,6 @@ func main() {
95
97
}
96
98
97
99
ensureVariable (testFocus , true , "test-focus is a required flag" )
98
- ensureVariable (imageType , true , "image type is a required flag. Available options include 'cos' and 'ubuntu'" )
99
100
100
101
if len (* gceRegion ) != 0 {
101
102
ensureVariable (gceZone , false , "gce-zone and gce-region cannot both be set" )
@@ -111,6 +112,12 @@ func main() {
111
112
112
113
if ! * bringupCluster {
113
114
ensureVariable (kubeFeatureGates , false , "kube-feature-gates set but not bringing up new cluster" )
115
+ } else {
116
+ ensureVariable (imageType , true , "image type is a required flag. Available options include 'cos' and 'ubuntu'" )
117
+ }
118
+
119
+ if * platform == "windows" {
120
+ ensureFlag (bringupCluster , false , "bringupCluster is set to false if it is for testing in windows cluster" )
114
121
}
115
122
116
123
if * deploymentStrat == "gke" {
@@ -132,7 +139,7 @@ func main() {
132
139
ensureVariable (testVersion , false , "Cannot set a test version when using a local k8s dir." )
133
140
}
134
141
135
- if * numNodes == - 1 {
142
+ if * numNodes == - 1 && * bringupCluster {
136
143
klog .Fatalf ("num-nodes must be set to number of nodes in cluster" )
137
144
}
138
145
@@ -157,28 +164,32 @@ func handle() error {
157
164
158
165
// If running in Prow, then acquire and set up a project through Boskos
159
166
if * inProw {
160
- project , _ := testutils .SetupProwConfig (* boskosResourceType )
161
-
162
167
oldProject , err := exec .Command ("gcloud" , "config" , "get-value" , "project" ).CombinedOutput ()
168
+ project := strings .TrimSpace (string (oldProject ))
163
169
if err != nil {
164
170
return fmt .Errorf ("failed to get gcloud project: %s, err: %v" , oldProject , err )
165
171
}
166
-
167
- err = setEnvProject (project )
168
- if err != nil {
169
- return fmt .Errorf ("failed to set project environment to %s: %v" , project , err )
170
- }
171
- defer func () {
172
- err = setEnvProject (string (oldProject ))
172
+ // TODO: Currently for prow tests with linux cluster, here it manually sets up a project from Boskos.
173
+ // For Windows, we used kubernetes_e2e.py which already set up the project and kubernetes automatically.
174
+ // Will update Linux in the future to use the same way as Windows test.
175
+ if * platform != "windows" {
176
+ newproject , _ := testutils .SetupProwConfig (* boskosResourceType )
177
+ err = setEnvProject (newproject )
173
178
if err != nil {
174
- klog .Errorf ("failed to set project environment to %s: %v" , oldProject , err )
179
+ return fmt .Errorf ("failed to set project environment to %s: %v" , newproject , err )
175
180
}
176
- }()
177
181
182
+ defer func () {
183
+ err = setEnvProject (string (oldProject ))
184
+ if err != nil {
185
+ klog .Errorf ("failed to set project environment to %s: %v" , oldProject , err )
186
+ }
187
+ }()
188
+ project = newproject
189
+ }
178
190
if * doDriverBuild {
179
- * stagingImage = fmt .Sprintf ("gcr.io/%s/gcp-persistent-disk-csi-driver" , project )
191
+ * stagingImage = fmt .Sprintf ("gcr.io/%s/gcp-persistent-disk-csi-driver" , strings . TrimSpace ( string ( project )) )
180
192
}
181
-
182
193
if _ , ok := os .LookupEnv ("USER" ); ! ok {
183
194
err = os .Setenv ("USER" , "prow" )
184
195
if err != nil {
@@ -189,7 +200,7 @@ func handle() error {
189
200
190
201
// Build and push the driver, if required. Defer the driver image deletion.
191
202
if * doDriverBuild {
192
- err := pushImage (pkgDir , * stagingImage , stagingVersion )
203
+ err := pushImage (pkgDir , * stagingImage , stagingVersion , * platform )
193
204
if err != nil {
194
205
return fmt .Errorf ("failed pushing image: %v" , err )
195
206
}
@@ -319,7 +330,7 @@ func handle() error {
319
330
var testSkip string
320
331
switch * deploymentStrat {
321
332
case "gce" :
322
- testSkip = generateGCETestSkip (clusterVersion )
333
+ testSkip = generateGCETestSkip (clusterVersion , * platform )
323
334
case "gke" :
324
335
testSkip = generateGKETestSkip (clusterVersion , * useGKEManagedDriver )
325
336
default :
@@ -328,7 +339,7 @@ func handle() error {
328
339
329
340
// Run the tests using the testDir kubernetes
330
341
if len (* storageClassFile ) != 0 {
331
- err = runCSITests (pkgDir , testDir , * testFocus , testSkip , * storageClassFile , * snapshotClassFile , cloudProviderArgs , * deploymentStrat )
342
+ err = runCSITests (* platform , pkgDir , testDir , * testFocus , testSkip , * storageClassFile , * snapshotClassFile , cloudProviderArgs , * deploymentStrat )
332
343
} else if * migrationTest {
333
344
err = runMigrationTests (pkgDir , testDir , * testFocus , testSkip , cloudProviderArgs )
334
345
} else {
@@ -342,7 +353,7 @@ func handle() error {
342
353
return nil
343
354
}
344
355
345
- func generateGCETestSkip (clusterVersion string ) string {
356
+ func generateGCETestSkip (clusterVersion , platform string ) string {
346
357
skipString := "\\ [Disruptive\\ ]|\\ [Serial\\ ]"
347
358
v := apimachineryversion .MustParseSemantic (clusterVersion )
348
359
@@ -352,10 +363,12 @@ func generateGCETestSkip(clusterVersion string) string {
352
363
if v .LessThan (apimachineryversion .MustParseSemantic ("1.16.0" )) {
353
364
skipString = skipString + "|volumeMode\\ sshould\\ snot\\ smount\\ s/\\ smap\\ sunused\\ svolumes\\ sin\\ sa\\ spod"
354
365
}
355
-
356
366
if v .LessThan (apimachineryversion .MustParseSemantic ("1.17.0" )) {
357
367
skipString = skipString + "|VolumeSnapshotDataSource"
358
368
}
369
+ if platform == "windows" {
370
+ skipString = skipString + "|\\ [LinuxOnly\\ ]"
371
+ }
359
372
return skipString
360
373
}
361
374
@@ -375,7 +388,6 @@ func generateGKETestSkip(clusterVersion string, use_gke_managed_driver bool) str
375
388
(! use_gke_managed_driver && (* curVer ).lessThan (mustParseVersion ("1.17.0" ))) {
376
389
skipString = skipString + "|VolumeSnapshotDataSource"
377
390
}
378
-
379
391
return skipString
380
392
}
381
393
@@ -396,8 +408,8 @@ func runMigrationTests(pkgDir, testDir, testFocus, testSkip string, cloudProvide
396
408
return runTestsWithConfig (testDir , testFocus , testSkip , "--storage.migratedPlugins=kubernetes.io/gce-pd" , cloudProviderArgs )
397
409
}
398
410
399
- func runCSITests (pkgDir , testDir , testFocus , testSkip , storageClassFile , snapshotClassFile string , cloudProviderArgs []string , deploymentStrat string ) error {
400
- testDriverConfigFile , err := generateDriverConfigFile (pkgDir , storageClassFile , snapshotClassFile , deploymentStrat )
411
+ func runCSITests (platform , pkgDir , testDir , testFocus , testSkip , storageClassFile , snapshotClassFile string , cloudProviderArgs []string , deploymentStrat string ) error {
412
+ testDriverConfigFile , err := generateDriverConfigFile (platform , pkgDir , storageClassFile , snapshotClassFile , deploymentStrat )
401
413
if err != nil {
402
414
return err
403
415
}
@@ -419,10 +431,12 @@ func runTestsWithConfig(testDir, testFocus, testSkip, testConfigArg string, clou
419
431
if ok {
420
432
reportArg = fmt .Sprintf ("-report-dir=%s" , artifactsDir )
421
433
}
422
-
423
- testArgs := fmt .Sprintf ("--ginkgo.focus=%s --ginkgo.skip=%s %s %s" ,
424
- testFocus ,
425
- testSkip ,
434
+ ginkgoArgs := fmt .Sprintf ("--ginkgo.focus=%s --ginkgo.skip=%s" , testFocus , testSkip )
435
+ if * platform == "windows" {
436
+ ginkgoArgs = ginkgoArgs + fmt .Sprintf (" --node-os-distro=%s" , * platform )
437
+ }
438
+ testArgs := fmt .Sprintf ("%s %s %s" ,
439
+ ginkgoArgs ,
426
440
testConfigArg ,
427
441
reportArg )
428
442
@@ -432,7 +446,6 @@ func runTestsWithConfig(testDir, testFocus, testSkip, testConfigArg string, clou
432
446
"--check-version-skew=false" ,
433
447
fmt .Sprintf ("--test_args=%s" , testArgs ),
434
448
}
435
-
436
449
kubeTestArgs = append (kubeTestArgs , cloudProviderArgs ... )
437
450
438
451
err = runCommand ("Running Tests" , exec .Command ("kubetest" , kubeTestArgs ... ))
0 commit comments