@@ -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,17 @@ 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 == "" && ! strings .Contains (skip , "VolumeSnapshotDataSource" ) {
682
+ skipString = skip + "|VolumeSnapshotDataSource"
683
+ } else 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
+ } else if testParams .snapshotClassFile != "" and ! strings .Contains (focus , "VolumeSnapshotDataSource" ) {
686
+ focus = focus + "|VolumeSnapshotDataSource"
687
+ }
688
+ ginkgoArgs := fmt .Sprintf ("--ginkgo.focus=%s --ginkgo.skip=%s" , focus , skip )
672
689
673
690
windowsArgs := ""
674
691
if testParams .platform == "windows" {
0 commit comments