mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
e2e storage: enable testing of ephemeral inline volumes with hostpath CSI driver
We need the 1.2.0 driver for that because that has support for detecting the volume mode dynamically, and we need to deploy a CSIDriver object which enables pod info (for the dynamic detection) and both modes (to satisfy the new mode sanity check).
This commit is contained in:
parent
6c6930a088
commit
cf125a2db3
@ -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,
|
||||
|
@ -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...
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user