The conceptual change is that the mode in which a volume gets handled is derived from it's spec, not from the ability of the driver. In practice, that is already how the code worked because it didn't actually look at CSIDriver.Spec.Mode at all. Therefore the code change itself is mostly just renaming "driver mode" to "volume mode". In some places (CanDeviceMount, CanAttach) the feature check that was used elsewhere seemed to be missing. Now their code path for ephemeral volumes are also only entered if that feature is enabled. The sanity check whether a CSI driver is being used correctly still needs to be implemented. Related-to: https://github.com/kubernetes/kubernetes/issues/79624
236 lines
7.6 KiB
Go
236 lines
7.6 KiB
Go
/*
|
|
Copyright 2018 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package testpatterns
|
|
|
|
import (
|
|
"k8s.io/api/core/v1"
|
|
storagev1 "k8s.io/api/storage/v1"
|
|
"k8s.io/kubernetes/test/e2e/framework/volume"
|
|
)
|
|
|
|
const (
|
|
// MinFileSize represents minimum file size (1 MiB) for testing
|
|
MinFileSize = 1 * volume.MiB
|
|
|
|
// FileSizeSmall represents small file size (1 MiB) for testing
|
|
FileSizeSmall = 1 * volume.MiB
|
|
// FileSizeMedium represents medium file size (100 MiB) for testing
|
|
FileSizeMedium = 100 * volume.MiB
|
|
// FileSizeLarge represents large file size (1 GiB) for testing
|
|
FileSizeLarge = 1 * volume.GiB
|
|
)
|
|
|
|
// TestVolType represents a volume type to be tested in a TestSuite
|
|
type TestVolType string
|
|
|
|
var (
|
|
// InlineVolume represents a volume type that is used inline in volumeSource
|
|
InlineVolume TestVolType = "InlineVolume"
|
|
// PreprovisionedPV represents a volume type for pre-provisioned Persistent Volume
|
|
PreprovisionedPV TestVolType = "PreprovisionedPV"
|
|
// DynamicPV represents a volume type for dynamic provisioned Persistent Volume
|
|
DynamicPV TestVolType = "DynamicPV"
|
|
// CSIInlineVolume represents a volume type that is defined inline and provided by a CSI driver.
|
|
CSIInlineVolume TestVolType = "CSIInlineVolume"
|
|
)
|
|
|
|
// TestSnapshotType represents a snapshot type to be tested in a TestSuite
|
|
type TestSnapshotType string
|
|
|
|
var (
|
|
// DynamicCreatedSnapshot represents a snapshot type for dynamic created snapshot
|
|
DynamicCreatedSnapshot TestSnapshotType = "DynamicSnapshot"
|
|
)
|
|
|
|
// TestPattern represents a combination of parameters to be tested in a TestSuite
|
|
type TestPattern struct {
|
|
Name string // Name of TestPattern
|
|
FeatureTag string // featureTag for the TestSuite
|
|
VolType TestVolType // Volume type of the volume
|
|
FsType string // Fstype of the volume
|
|
VolMode v1.PersistentVolumeMode // PersistentVolumeMode of the volume
|
|
SnapshotType TestSnapshotType // Snapshot type of the snapshot
|
|
BindingMode storagev1.VolumeBindingMode // VolumeBindingMode of the volume
|
|
AllowExpansion bool // AllowVolumeExpansion flag of the StorageClass
|
|
}
|
|
|
|
var (
|
|
// Definitions for default fsType
|
|
|
|
// DefaultFsInlineVolume is TestPattern for "Inline-volume (default fs)"
|
|
DefaultFsInlineVolume = TestPattern{
|
|
Name: "Inline-volume (default fs)",
|
|
VolType: InlineVolume,
|
|
}
|
|
// DefaultFsPreprovisionedPV is TestPattern for "Pre-provisioned PV (default fs)"
|
|
DefaultFsPreprovisionedPV = TestPattern{
|
|
Name: "Pre-provisioned PV (default fs)",
|
|
VolType: PreprovisionedPV,
|
|
}
|
|
// DefaultFsDynamicPV is TestPattern for "Dynamic PV (default fs)"
|
|
DefaultFsDynamicPV = TestPattern{
|
|
Name: "Dynamic PV (default fs)",
|
|
VolType: DynamicPV,
|
|
}
|
|
|
|
// Definitions for ext3
|
|
|
|
// Ext3InlineVolume is TestPattern for "Inline-volume (ext3)"
|
|
Ext3InlineVolume = TestPattern{
|
|
Name: "Inline-volume (ext3)",
|
|
VolType: InlineVolume,
|
|
FsType: "ext3",
|
|
}
|
|
// Ext3PreprovisionedPV is TestPattern for "Pre-provisioned PV (ext3)"
|
|
Ext3PreprovisionedPV = TestPattern{
|
|
Name: "Pre-provisioned PV (ext3)",
|
|
VolType: PreprovisionedPV,
|
|
FsType: "ext3",
|
|
}
|
|
// Ext3DynamicPV is TestPattern for "Dynamic PV (ext3)"
|
|
Ext3DynamicPV = TestPattern{
|
|
Name: "Dynamic PV (ext3)",
|
|
VolType: DynamicPV,
|
|
FsType: "ext3",
|
|
}
|
|
|
|
// Definitions for ext4
|
|
|
|
// Ext4InlineVolume is TestPattern for "Inline-volume (ext4)"
|
|
Ext4InlineVolume = TestPattern{
|
|
Name: "Inline-volume (ext4)",
|
|
VolType: InlineVolume,
|
|
FsType: "ext4",
|
|
}
|
|
// Ext4PreprovisionedPV is TestPattern for "Pre-provisioned PV (ext4)"
|
|
Ext4PreprovisionedPV = TestPattern{
|
|
Name: "Pre-provisioned PV (ext4)",
|
|
VolType: PreprovisionedPV,
|
|
FsType: "ext4",
|
|
}
|
|
// Ext4DynamicPV is TestPattern for "Dynamic PV (ext4)"
|
|
Ext4DynamicPV = TestPattern{
|
|
Name: "Dynamic PV (ext4)",
|
|
VolType: DynamicPV,
|
|
FsType: "ext4",
|
|
}
|
|
|
|
// Definitions for xfs
|
|
|
|
// XfsInlineVolume is TestPattern for "Inline-volume (xfs)"
|
|
XfsInlineVolume = TestPattern{
|
|
Name: "Inline-volume (xfs)",
|
|
VolType: InlineVolume,
|
|
FsType: "xfs",
|
|
FeatureTag: "[Slow]",
|
|
}
|
|
// XfsPreprovisionedPV is TestPattern for "Pre-provisioned PV (xfs)"
|
|
XfsPreprovisionedPV = TestPattern{
|
|
Name: "Pre-provisioned PV (xfs)",
|
|
VolType: PreprovisionedPV,
|
|
FsType: "xfs",
|
|
FeatureTag: "[Slow]",
|
|
}
|
|
// XfsDynamicPV is TestPattern for "Dynamic PV (xfs)"
|
|
XfsDynamicPV = TestPattern{
|
|
Name: "Dynamic PV (xfs)",
|
|
VolType: DynamicPV,
|
|
FsType: "xfs",
|
|
FeatureTag: "[Slow]",
|
|
}
|
|
|
|
// Definitions for ntfs
|
|
|
|
// NtfsInlineVolume is TestPattern for "Inline-volume (ntfs)"
|
|
NtfsInlineVolume = TestPattern{
|
|
Name: "Inline-volume (ntfs)",
|
|
VolType: InlineVolume,
|
|
FsType: "ntfs",
|
|
FeatureTag: "[sig-windows]",
|
|
}
|
|
// NtfsPreprovisionedPV is TestPattern for "Pre-provisioned PV (ntfs)"
|
|
NtfsPreprovisionedPV = TestPattern{
|
|
Name: "Pre-provisioned PV (ntfs)",
|
|
VolType: PreprovisionedPV,
|
|
FsType: "ntfs",
|
|
FeatureTag: "[sig-windows]",
|
|
}
|
|
// NtfsDynamicPV is TestPattern for "Dynamic PV (xfs)"
|
|
NtfsDynamicPV = TestPattern{
|
|
Name: "Dynamic PV (ntfs)",
|
|
VolType: DynamicPV,
|
|
FsType: "ntfs",
|
|
FeatureTag: "[sig-windows]",
|
|
}
|
|
|
|
// Definitions for Filesystem volume mode
|
|
|
|
// FsVolModePreprovisionedPV is TestPattern for "Pre-provisioned PV (filesystem)"
|
|
FsVolModePreprovisionedPV = TestPattern{
|
|
Name: "Pre-provisioned PV (filesystem volmode)",
|
|
VolType: PreprovisionedPV,
|
|
VolMode: v1.PersistentVolumeFilesystem,
|
|
}
|
|
// FsVolModeDynamicPV is TestPattern for "Dynamic PV (filesystem)"
|
|
FsVolModeDynamicPV = TestPattern{
|
|
Name: "Dynamic PV (filesystem volmode)",
|
|
VolType: DynamicPV,
|
|
VolMode: v1.PersistentVolumeFilesystem,
|
|
}
|
|
|
|
// Definitions for block volume mode
|
|
|
|
// BlockVolModePreprovisionedPV is TestPattern for "Pre-provisioned PV (block)"
|
|
BlockVolModePreprovisionedPV = TestPattern{
|
|
Name: "Pre-provisioned PV (block volmode)",
|
|
VolType: PreprovisionedPV,
|
|
VolMode: v1.PersistentVolumeBlock,
|
|
}
|
|
// BlockVolModeDynamicPV is TestPattern for "Dynamic PV (block)"
|
|
BlockVolModeDynamicPV = TestPattern{
|
|
Name: "Dynamic PV (block volmode)",
|
|
VolType: DynamicPV,
|
|
VolMode: v1.PersistentVolumeBlock,
|
|
}
|
|
|
|
// Definitions for snapshot case
|
|
|
|
// DynamicSnapshot is TestPattern for "Dynamic snapshot"
|
|
DynamicSnapshot = TestPattern{
|
|
Name: "Dynamic Snapshot",
|
|
SnapshotType: DynamicCreatedSnapshot,
|
|
}
|
|
|
|
// Definitions for volume expansion case
|
|
|
|
// DefaultFsDynamicPVAllowExpansion is TestPattern for "Dynamic PV (default fs)(allowExpansion)"
|
|
DefaultFsDynamicPVAllowExpansion = TestPattern{
|
|
Name: "Dynamic PV (default fs)(allowExpansion)",
|
|
VolType: DynamicPV,
|
|
BindingMode: storagev1.VolumeBindingWaitForFirstConsumer,
|
|
AllowExpansion: true,
|
|
}
|
|
// BlockVolModeDynamicPVAllowExpansion is TestPattern for "Dynamic PV (block volmode)(allowExpansion)"
|
|
BlockVolModeDynamicPVAllowExpansion = TestPattern{
|
|
Name: "Dynamic PV (block volmode)(allowExpansion)",
|
|
VolType: DynamicPV,
|
|
VolMode: v1.PersistentVolumeBlock,
|
|
BindingMode: storagev1.VolumeBindingWaitForFirstConsumer,
|
|
AllowExpansion: true,
|
|
}
|
|
)
|