Skip to content

Commit d94b17e

Browse files
committed
Make driver test capabilities configurable and remove expansion from GKE tests
1 parent 6db9dbf commit d94b17e

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

test/k8s-integration/config/test-config-template.in

+2-14
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,8 @@ DriverInfo:
1212
# xfs: XFS only available on Ubuntu
1313
# ntfs: NTFS only available on Windows
1414
Capabilities:
15-
persistence: true
16-
block: true
17-
fsGroup: true
18-
exec: true
19-
# snapshotDataSource:
20-
# pvcDataSource:
21-
multipods: true
22-
# RWX:
23-
controllerExpansion: true
24-
nodeExpansion: true
25-
# volumeLimits: # PD Supports volume limits but test is very slow
26-
# singleNodeVolume:
27-
topology: true
28-
# dataSource:
15+
{{range .Capabilities}} {{ . }}: true
16+
{{end}}
2917
SupportedMountOption:
3018
debug:
3119
nouid32:

test/k8s-integration/driver-config.go

+37-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package main
22

33
import (
44
"bufio"
5+
"fmt"
56
"os"
67
"path/filepath"
78
"text/template"
89
)
910

1011
type driverConfig struct {
1112
StorageClassFile string
13+
Capabilities []string
1214
}
1315

1416
const (
@@ -19,7 +21,7 @@ const (
1921

2022
// generateDriverConfigFile loads a testdriver config template and creates a file
2123
// with the test-specific configuration
22-
func generateDriverConfigFile(pkgDir, storageClassFile string) (string, error) {
24+
func generateDriverConfigFile(pkgDir, storageClassFile, deploymentStrat string) (string, error) {
2325
// Load template
2426
t, err := template.ParseFiles(filepath.Join(pkgDir, testConfigDir, configTemplateFile))
2527
if err != nil {
@@ -37,9 +39,42 @@ func generateDriverConfigFile(pkgDir, storageClassFile string) (string, error) {
3739
w := bufio.NewWriter(f)
3840
defer w.Flush()
3941

40-
// Fill in template parameters
42+
// Fill in template parameters. Capabilities can be found here:
43+
// https://github.com/kubernetes/kubernetes/blob/b717be8269a4f381ab6c23e711e8924bc1f64c93/test/e2e/storage/testsuites/testdriver.go#L136
44+
caps := []string{
45+
"persistence",
46+
"block",
47+
"fsGroup",
48+
"exec",
49+
"multipods",
50+
"topology",
51+
}
52+
53+
/* Unsupported Capabilities:
54+
snapshotDataSource
55+
pvcDataSource
56+
RWX
57+
volumeLimits # PD Supports volume limits but test is very slow
58+
singleNodeVolume
59+
dataSource
60+
*/
61+
62+
// TODO: Support adding/removing capabilities based on Kubernetes version.
63+
switch deploymentStrat {
64+
case "gke":
65+
case "gce":
66+
// TODO: OSS K8S supports volume expansion for CSI by default in 1.16+;
67+
// however, at time of writing GKE does not support K8S 1.16+. Add these
68+
// capabilities for both deployment strategies when GKE Supports CSI
69+
// Expansion by default.
70+
caps = append(caps, "controllerExpansion", "nodeExpansion")
71+
default:
72+
return "", fmt.Errorf("got unknown deployment strat %s, expected gce or gke", deploymentStrat)
73+
}
74+
4175
params := driverConfig{
4276
StorageClassFile: filepath.Join(pkgDir, testConfigDir, storageClassFile),
77+
Capabilities: caps,
4378
}
4479

4580
// Write config file

test/k8s-integration/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func handle() error {
294294

295295
// Run the tests using the testDir kubernetes
296296
if len(*storageClassFile) != 0 {
297-
err = runCSITests(pkgDir, testDir, *testFocus, *storageClassFile, cloudProviderArgs)
297+
err = runCSITests(pkgDir, testDir, *testFocus, *storageClassFile, cloudProviderArgs, *deploymentStrat)
298298
} else if *migrationTest {
299299
err = runMigrationTests(pkgDir, testDir, *testFocus, cloudProviderArgs)
300300
} else {
@@ -325,8 +325,8 @@ func runMigrationTests(pkgDir, testDir, testFocus string, cloudProviderArgs []st
325325
return runTestsWithConfig(testDir, testFocus, "--storage.migratedPlugins=kubernetes.io/gce-pd", cloudProviderArgs)
326326
}
327327

328-
func runCSITests(pkgDir, testDir, testFocus, storageClassFile string, cloudProviderArgs []string) error {
329-
testDriverConfigFile, err := generateDriverConfigFile(pkgDir, storageClassFile)
328+
func runCSITests(pkgDir, testDir, testFocus, storageClassFile string, cloudProviderArgs []string, deploymentStrat string) error {
329+
testDriverConfigFile, err := generateDriverConfigFile(pkgDir, storageClassFile, deploymentStrat)
330330
if err != nil {
331331
return err
332332
}

0 commit comments

Comments
 (0)