@@ -93,6 +93,7 @@ type testParameters struct {
93
93
k8sSourceDir string
94
94
testFocus string
95
95
testSkip string
96
+ storageClassFile string
96
97
snapshotClassFile string
97
98
cloudProviderArgs []string
98
99
deploymentStrategy string
@@ -501,21 +502,27 @@ func handle() error {
501
502
applicableSnapshotClassFiles = append (applicableSnapshotClassFiles , snapshotClassFile )
502
503
}
503
504
}
504
- if len (applicableSnapshotClassFiles ) == 0 {
505
- // when no snapshot class specified, we run the tests without snapshot capability
506
- applicableSnapshotClassFiles = append (applicableSnapshotClassFiles , "" )
507
- }
508
505
var ginkgoErrors []string
509
506
var testOutputDirs []string
507
+
508
+ // Run non-snapshot tests.
509
+ testParams .snapshotClassFile = ""
510
510
for _ , scFile := range applicableStorageClassFiles {
511
511
outputDir := strings .TrimSuffix (scFile , ".yaml" )
512
+ testOutputDirs = append (testOutputDirs , outputDir )
513
+ testParams .storageClassFile = scFile
514
+ if err = runCSITests (testParams , outputDir ); err != nil {
515
+ ginkgoErrors = append (ginkgoErrors , err .Error ())
516
+ }
517
+ }
518
+ // Run snapshot tests, if there are applicable files, using the first storage class.
519
+ if len (applicableStorageClassFiles ) > 0 {
520
+ testParams .storageClassFile = applicableStorageClassFiles [0 ]
512
521
for _ , snapshotClassFile := range applicableSnapshotClassFiles {
513
- if len (snapshotClassFile ) != 0 {
514
- outputDir = fmt .Sprintf ("%s--%s" , outputDir , strings .TrimSuffix (snapshotClassFile , ".yaml" ))
515
- }
516
- testOutputDirs = append (testOutputDirs , outputDir )
517
522
testParams .snapshotClassFile = snapshotClassFile
518
- if err = runCSITests (testParams , scFile , outputDir ); err != nil {
523
+ outputDir := strings .TrimSuffix (snapshotClassFile , ".yaml" )
524
+ testOutputDirs = append (testOutputDirs , outputDir )
525
+ if err = runCSITests (testParams , outputDir ); err != nil {
519
526
ginkgoErrors = append (ginkgoErrors , err .Error ())
520
527
}
521
528
}
@@ -633,8 +640,8 @@ func runMigrationTests(testParams *testParameters) error {
633
640
return runTestsWithConfig (testParams , "--storage.migratedPlugins=kubernetes.io/gce-pd" , "" )
634
641
}
635
642
636
- func runCSITests (testParams * testParameters , storageClassFile string , reportPrefix string ) error {
637
- testDriverConfigFile , err := generateDriverConfigFile (testParams , storageClassFile )
643
+ func runCSITests (testParams * testParameters , reportPrefix string ) error {
644
+ testDriverConfigFile , err := generateDriverConfigFile (testParams )
638
645
if err != nil {
639
646
return fmt .Errorf ("failed to generated driver config: %w" , err )
640
647
}
@@ -668,7 +675,20 @@ func runTestsWithConfig(testParams *testParameters, testConfigArg, reportPrefix
668
675
kubetestDumpDir = artifactsDir
669
676
}
670
677
}
671
- ginkgoArgs := fmt .Sprintf ("--ginkgo.focus=%s --ginkgo.skip=%s" , testParams .testFocus , testParams .testSkip )
678
+
679
+ focus := testParams .testFocus
680
+ skip := testParams .testSkip
681
+ // If testParams.snapshotClassFile is empty, then snapshot tests will be automatically skipped. Otherwise confirm
682
+ // the right tests are run.
683
+ if testParams .snapshotClassFile != "" && strings .Contains (skip , "VolumeSnapshotDataSource" ) {
684
+ return fmt .Errorf ("Snapshot class file %s specified, but snapshot tests are skipped: %s" , testParams .snapshotClassFile , skip )
685
+ }
686
+ if testParams .snapshotClassFile != "" {
687
+ // Run exactly the snapshot tests, if there is a snapshot class file.
688
+ focus = "Driver:\\ s*csi-gcepd.*Feature:VolumeSnapshotDataSource"
689
+ }
690
+
691
+ ginkgoArgs := fmt .Sprintf ("--ginkgo.focus=%s --ginkgo.skip=%s" , focus , skip )
672
692
673
693
windowsArgs := ""
674
694
if testParams .platform == "windows" {
@@ -728,8 +748,8 @@ func runTestsWithConfig(testParams *testParameters, testConfigArg, reportPrefix
728
748
kubeTest2Args = append (kubeTest2Args , fmt .Sprintf ("--test-package-marker=latest-%s.txt" , * testVersion ))
729
749
}
730
750
}
731
- kubeTest2Args = append (kubeTest2Args , fmt .Sprintf ("--focus-regex=%s" , testParams . testFocus ))
732
- kubeTest2Args = append (kubeTest2Args , fmt .Sprintf ("--skip-regex=%s" , testParams . testSkip ))
751
+ kubeTest2Args = append (kubeTest2Args , fmt .Sprintf ("--focus-regex=%s" , focus ))
752
+ kubeTest2Args = append (kubeTest2Args , fmt .Sprintf ("--skip-regex=%s" , skip ))
733
753
kubeTest2Args = append (kubeTest2Args , fmt .Sprintf ("--parallel=%d" , testParams .parallel ))
734
754
kubeTest2Args = append (kubeTest2Args , fmt .Sprintf ("--test-args=%s %s" , testConfigArg , windowsArgs ))
735
755
0 commit comments