Skip to content

Commit 093027c

Browse files
committed
e2e/storage: ensure that also external storage classes are unique
One previously undocumented expectation is that GetDynamicProvisionStorageClass can be called more than once per test and then each time returns a new, unique storage class. The in-memory implementation in driveroperations.go:GetStorageClass ensured that, but loading from a .yaml file didn't. This caused the multivolume tests to fail when applied to an already installed GCE driver with the -storage.testdriver parameter.
1 parent 62c5c63 commit 093027c

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

test/e2e/storage/external/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ go_library(
1111
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
1212
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
1313
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
14+
"//staging/src/k8s.io/apiserver/pkg/storage/names:go_default_library",
1415
"//staging/src/k8s.io/client-go/kubernetes/scheme:go_default_library",
1516
"//test/e2e/framework:go_default_library",
1617
"//test/e2e/storage/testpatterns:go_default_library",

test/e2e/storage/external/external.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/apimachinery/pkg/runtime"
2828
"k8s.io/apimachinery/pkg/runtime/schema"
2929
"k8s.io/apimachinery/pkg/util/sets"
30+
"k8s.io/apiserver/pkg/storage/names"
3031
"k8s.io/client-go/kubernetes/scheme"
3132
"k8s.io/kubernetes/test/e2e/framework"
3233
"k8s.io/kubernetes/test/e2e/storage/testpatterns"
@@ -242,6 +243,9 @@ func (d *driverDefinition) GetDynamicProvisionStorageClass(config *testsuites.Pe
242243

243244
sc, ok := items[0].(*storagev1.StorageClass)
244245
gomega.Expect(ok).To(gomega.BeTrue(), "storage class from %s", d.StorageClass.FromFile)
246+
// Ensure that we can load more than once as required for
247+
// GetDynamicProvisionStorageClass by adding a random suffix.
248+
sc.Name = names.SimpleNameGenerator.GenerateName(sc.Name + "-")
245249
if fsType != "" {
246250
if sc.Parameters == nil {
247251
sc.Parameters = map[string]string{}

test/e2e/storage/testsuites/testdriver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ type PreprovisionedPVTestDriver interface {
8888
type DynamicPVTestDriver interface {
8989
TestDriver
9090
// GetDynamicProvisionStorageClass returns a StorageClass dynamic provision Persistent Volume.
91+
// The StorageClass must be created in the current test's namespace and have
92+
// a unique name inside that namespace because GetDynamicProvisionStorageClass might
93+
// be called more than once per test.
9194
// It will set fsType to the StorageClass, if TestDriver supports it.
9295
// It will return nil, if the TestDriver doesn't support it.
9396
GetDynamicProvisionStorageClass(config *PerTestConfig, fsType string) *storagev1.StorageClass

0 commit comments

Comments
 (0)