diff --git a/test/e2e/storage/csi_volumes.go b/test/e2e/storage/csi_volumes.go index 5d1d01c2028..706b9f7dd66 100644 --- a/test/e2e/storage/csi_volumes.go +++ b/test/e2e/storage/csi_volumes.go @@ -42,6 +42,7 @@ var csiTestDrivers = []func() testsuites.TestDriver{ // List of testSuites to be executed in below loop var csiTestSuites = []func() testsuites.TestSuite{ + testsuites.InitEphemeralTestSuite, testsuites.InitVolumesTestSuite, testsuites.InitVolumeIOTestSuite, testsuites.InitVolumeModeTestSuite, diff --git a/test/e2e/storage/drivers/csi.go b/test/e2e/storage/drivers/csi.go index 87d511a45f3..e70dd468925 100644 --- a/test/e2e/storage/drivers/csi.go +++ b/test/e2e/storage/drivers/csi.go @@ -62,11 +62,12 @@ const ( // hostpathCSI type hostpathCSIDriver struct { - driverInfo testsuites.DriverInfo - manifests []string + driverInfo testsuites.DriverInfo + manifests []string + volumeAttributes []map[string]string } -func initHostPathCSIDriver(name string, capabilities map[testsuites.Capability]bool, manifests ...string) testsuites.TestDriver { +func initHostPathCSIDriver(name string, capabilities map[testsuites.Capability]bool, volumeAttributes []map[string]string, manifests ...string) testsuites.TestDriver { return &hostpathCSIDriver{ driverInfo: testsuites.DriverInfo{ Name: name, @@ -77,13 +78,15 @@ func initHostPathCSIDriver(name string, capabilities map[testsuites.Capability]b ), Capabilities: capabilities, }, - manifests: manifests, + manifests: manifests, + volumeAttributes: volumeAttributes, } } var _ testsuites.TestDriver = &hostpathCSIDriver{} var _ testsuites.DynamicPVTestDriver = &hostpathCSIDriver{} var _ testsuites.SnapshottableTestDriver = &hostpathCSIDriver{} +var _ testsuites.EphemeralTestDriver = &hostpathCSIDriver{} // InitHostPathCSIDriver returns hostpathCSIDriver that implements TestDriver interface func InitHostPathCSIDriver() testsuites.TestDriver { @@ -97,15 +100,20 @@ func InitHostPathCSIDriver() testsuites.TestDriver { } return initHostPathCSIDriver("csi-hostpath", capabilities, + // Volume attributes don't matter, but we have to provide at least one map. + []map[string]string{ + {"foo": "bar"}, + }, "test/e2e/testing-manifests/storage-csi/external-attacher/rbac.yaml", "test/e2e/testing-manifests/storage-csi/external-provisioner/rbac.yaml", "test/e2e/testing-manifests/storage-csi/external-snapshotter/rbac.yaml", "test/e2e/testing-manifests/storage-csi/external-resizer/rbac.yaml", "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-attacher.yaml", - "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-provisioner.yaml", - "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-snapshotter.yaml", - "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-resizer.yaml", + "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-driverinfo.yaml", "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-plugin.yaml", + "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-provisioner.yaml", + "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-resizer.yaml", + "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-snapshotter.yaml", "test/e2e/testing-manifests/storage-csi/hostpath/hostpath/e2e-test-rbac.yaml", ) } @@ -115,6 +123,9 @@ func (h *hostpathCSIDriver) GetDriverInfo() *testsuites.DriverInfo { } func (h *hostpathCSIDriver) SkipUnsupportedTest(pattern testpatterns.TestPattern) { + if pattern.VolType == testpatterns.CSIInlineVolume && len(h.volumeAttributes) == 0 { + framework.Skipf("%s has no volume attributes defined, doesn't support ephemeral inline volumes", h.driverInfo.Name) + } } func (h *hostpathCSIDriver) GetDynamicProvisionStorageClass(config *testsuites.PerTestConfig, fsType string) *storagev1.StorageClass { @@ -126,6 +137,14 @@ func (h *hostpathCSIDriver) GetDynamicProvisionStorageClass(config *testsuites.P return testsuites.GetStorageClass(provisioner, parameters, nil, ns, suffix) } +func (h *hostpathCSIDriver) GetVolumeAttributes(config *testsuites.PerTestConfig, volumeNumber int) map[string]string { + return h.volumeAttributes[volumeNumber%len(h.volumeAttributes)] +} + +func (h *hostpathCSIDriver) GetCSIDriverName(config *testsuites.PerTestConfig) string { + return config.GetUniqueDriverName() +} + func (h *hostpathCSIDriver) GetSnapshotClass(config *testsuites.PerTestConfig) *unstructured.Unstructured { snapshotter := config.GetUniqueDriverName() parameters := map[string]string{} @@ -303,7 +322,7 @@ func (m *mockCSIDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTest NodeName: config.ClientNodeName, PodInfo: m.podInfo, CanAttach: &m.attachable, - VolumeLifecycleModes: []storagev1beta1.VolumeLifecycleMode{ + VolumeLifecycleModes: &[]storagev1beta1.VolumeLifecycleMode{ storagev1beta1.VolumeLifecyclePersistent, storagev1beta1.VolumeLifecycleEphemeral, }, @@ -327,6 +346,7 @@ func (m *mockCSIDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTest func InitHostPathV0CSIDriver() testsuites.TestDriver { return initHostPathCSIDriver("csi-hostpath-v0", map[testsuites.Capability]bool{testsuites.CapPersistence: true, testsuites.CapMultiPODs: true}, + nil, /* no volume attributes -> no ephemeral volume testing */ // Using the current set of rbac.yaml files is problematic here because they don't // match the version of the rules that were written for the releases of external-attacher // and external-provisioner that we are using here. It happens to work in practice... diff --git a/test/e2e/storage/utils/deployment.go b/test/e2e/storage/utils/deployment.go index 067e8cd20f4..c8161f7f057 100644 --- a/test/e2e/storage/utils/deployment.go +++ b/test/e2e/storage/utils/deployment.go @@ -131,7 +131,9 @@ func PatchCSIDeployment(f *framework.Framework, o PatchCSIOptions, object interf if o.CanAttach != nil { object.Spec.AttachRequired = o.CanAttach } - object.Spec.VolumeLifecycleModes = o.VolumeLifecycleModes + if o.VolumeLifecycleModes != nil { + object.Spec.VolumeLifecycleModes = *o.VolumeLifecycleModes + } } return nil @@ -171,8 +173,8 @@ type PatchCSIOptions struct { // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. CanAttach *bool - // The value to use for the CSIDriver.Spec.VolumeLifecycleModes + // If not nil, the value to use for the CSIDriver.Spec.VolumeLifecycleModes // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. - VolumeLifecycleModes []storagev1beta1.VolumeLifecycleMode + VolumeLifecycleModes *[]storagev1beta1.VolumeLifecycleMode } diff --git a/test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-driverinfo.yaml b/test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-driverinfo.yaml new file mode 100644 index 00000000000..b4371003b34 --- /dev/null +++ b/test/e2e/testing-manifests/storage-csi/hostpath/hostpath/csi-hostpath-driverinfo.yaml @@ -0,0 +1,10 @@ +apiVersion: storage.k8s.io/v1beta1 +kind: CSIDriver +metadata: + name: hostpath.csi.k8s.io +spec: + # Supports both modes, but needs pod info for that to determine the actual mode. + podInfoOnMount: true + volumeLifecycleModes: + - Persistent + - Ephemeral