From a70bec465da4a4a9087381dae615a54c58397488 Mon Sep 17 00:00:00 2001 From: Timo Reimann Date: Fri, 6 Dec 2019 13:57:20 +0100 Subject: [PATCH] e2e: support long CSI driver names The storage e2e test suite uses given CSI driver names as pod names. For pod names that also get enriched by a prefix and suffix, it is very easy to exceed the 63 character limit that pod names are subject to, thereby causing tests to fail. This change fixes the described problem by omitting the driver name from the pod name suffix. It also allows us to drop VolumeResource.VolType. --- test/e2e/storage/testsuites/base.go | 5 ----- test/e2e/storage/testsuites/subpath.go | 12 +++++++----- test/e2e/storage/testsuites/volumes.go | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/test/e2e/storage/testsuites/base.go b/test/e2e/storage/testsuites/base.go index 9b13cc1632e..9cbc149f2a5 100644 --- a/test/e2e/storage/testsuites/base.go +++ b/test/e2e/storage/testsuites/base.go @@ -171,7 +171,6 @@ func skipUnsupportedTest(driver TestDriver, pattern testpatterns.TestPattern) { type VolumeResource struct { Config *PerTestConfig Pattern testpatterns.TestPattern - VolType string VolSource *v1.VolumeSource Pvc *v1.PersistentVolumeClaim Pv *v1.PersistentVolume @@ -199,7 +198,6 @@ func CreateVolumeResource(driver TestDriver, config *PerTestConfig, pattern test framework.Logf("Creating resource for inline volume") if iDriver, ok := driver.(InlineVolumeTestDriver); ok { r.VolSource = iDriver.GetVolumeSource(false, pattern.FsType, r.Volume) - r.VolType = dInfo.Name } case testpatterns.PreprovisionedPV: framework.Logf("Creating resource for pre-provisioned PV") @@ -209,7 +207,6 @@ func CreateVolumeResource(driver TestDriver, config *PerTestConfig, pattern test r.Pv, r.Pvc = createPVCPV(f, dInfo.Name, pvSource, volumeNodeAffinity, pattern.VolMode, dInfo.RequiredAccessModes) r.VolSource = createVolumeSource(r.Pvc.Name, false /* readOnly */) } - r.VolType = fmt.Sprintf("%s-preprovisionedPV", dInfo.Name) } case testpatterns.DynamicPV: framework.Logf("Creating resource for dynamic PV") @@ -238,12 +235,10 @@ func CreateVolumeResource(driver TestDriver, config *PerTestConfig, pattern test f, dInfo.Name, claimSize, r.Sc, pattern.VolMode, dInfo.RequiredAccessModes) r.VolSource = createVolumeSource(r.Pvc.Name, false /* readOnly */) } - r.VolType = fmt.Sprintf("%s-dynamicPV", dInfo.Name) } case testpatterns.CSIInlineVolume: framework.Logf("Creating resource for CSI ephemeral inline volume") if eDriver, ok := driver.(EphemeralTestDriver); ok { - r.VolType = fmt.Sprintf("%s-ephemeral", dInfo.Name) attributes, _, _ := eDriver.GetVolume(config, 0) r.VolSource = &v1.VolumeSource{ CSI: &v1.CSIVolumeSource{ diff --git a/test/e2e/storage/testsuites/subpath.go b/test/e2e/storage/testsuites/subpath.go index d9faf9d76c6..18076b3af41 100644 --- a/test/e2e/storage/testsuites/subpath.go +++ b/test/e2e/storage/testsuites/subpath.go @@ -148,7 +148,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T } subPath := f.Namespace.Name - l.pod = SubpathTestPod(f, subPath, l.resource.VolType, l.resource.VolSource, true) + l.pod = SubpathTestPod(f, subPath, string(volType), l.resource.VolSource, true) l.pod.Spec.NodeName = l.config.ClientNodeName l.pod.Spec.NodeSelector = l.config.ClientNodeSelector @@ -186,6 +186,8 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T validateMigrationVolumeOpCounts(f.ClientSet, driver.GetDriverInfo().InTreePluginName, l.intreeOps, l.migratedOps) } + driverName := driver.GetDriverInfo().Name + ginkgo.It("should support non-existent path", func() { init() defer cleanup() @@ -348,9 +350,9 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T init() defer cleanup() - if strings.HasPrefix(l.resource.VolType, "hostPath") || strings.HasPrefix(l.resource.VolType, "csi-hostpath") { + if strings.HasPrefix(driverName, "hostPath") { // TODO: This skip should be removed once #61446 is fixed - framework.Skipf("%s volume type does not support reconstruction, skipping", l.resource.VolType) + framework.Skipf("Driver %s does not support reconstruction, skipping", driverName) } testSubpathReconstruction(f, l.hostExec, l.pod, true) @@ -390,7 +392,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T init() defer cleanup() if l.roVolSource == nil { - framework.Skipf("Volume type %v doesn't support readOnly source", l.resource.VolType) + framework.Skipf("Driver %s on volume type %s doesn't support readOnly source", driverName, pattern.VolType) } origpod := l.pod.DeepCopy() @@ -418,7 +420,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T init() defer cleanup() if l.roVolSource == nil { - framework.Skipf("Volume type %v doesn't support readOnly source", l.resource.VolType) + framework.Skipf("Driver %s on volume type %s doesn't support readOnly source", driverName, pattern.VolType) } // Format the volume while it's writable diff --git a/test/e2e/storage/testsuites/volumes.go b/test/e2e/storage/testsuites/volumes.go index b19ab02792e..90de74d55b6 100644 --- a/test/e2e/storage/testsuites/volumes.go +++ b/test/e2e/storage/testsuites/volumes.go @@ -193,7 +193,7 @@ func (t *volumesTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T init() defer cleanup() - testScriptInPod(f, l.resource.VolType, l.resource.VolSource, l.config) + testScriptInPod(f, string(pattern.VolType), l.resource.VolSource, l.config) }) } }