const ( // SnapshotGroup is the snapshot CRD api group SnapshotGroup = "snapshot.storage.k8s.io" // SnapshotAPIVersion is the snapshot CRD api version SnapshotAPIVersion = "snapshot.storage.k8s.io/v1" )
var ( // SnapshotGVR is GroupVersionResource for volumesnapshots SnapshotGVR = schema.GroupVersionResource{Group: SnapshotGroup, Version: "v1", Resource: "volumesnapshots"} // SnapshotClassGVR is GroupVersionResource for volumesnapshotclasses SnapshotClassGVR = schema.GroupVersionResource{Group: SnapshotGroup, Version: "v1", Resource: "volumesnapshotclasses"} // SnapshotContentGVR is GroupVersionResource for volumesnapshotcontents SnapshotContentGVR = schema.GroupVersionResource{Group: SnapshotGroup, Version: "v1", Resource: "volumesnapshotcontents"} )
SIGDescribe annotates the test with the SIG label.
var SIGDescribe = framework.SIGDescribe("storage")
func ChangeFilePathGidInPod(f *framework.Framework, filePath, targetGid string, pod *v1.Pod)
ChangeFilePathGidInPod changes the GID of the target filepath.
func CheckReadFromPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, directIO bool, path string, len int, seed int64)
CheckReadFromPath validate that file can be properly read.
Note: directIO does not work with (default) BusyBox Pods. A requirement for directIO to function correctly, is to read whole sector(s) for Block-mode PVCs (normally a sector is 512 bytes), or memory pages for files (commonly 4096 bytes).
func CheckReadWriteToPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, path string)
CheckReadWriteToPath check that path can b e read and written
func CheckWriteToPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, nocache bool, path string, len int, seed int64)
CheckWriteToPath that file can be properly written.
Note: nocache does not work with (default) BusyBox Pods. To read without caching, enable directIO with CheckReadFromPath and check the hints about the len requirements.
func CreateDriverNamespace(ctx context.Context, f *framework.Framework) *v1.Namespace
CreateDriverNamespace creates a namespace for CSI driver installation. The namespace is still tracked and ensured that gets deleted when test terminates.
func CreateFromManifests(ctx context.Context, f *framework.Framework, driverNamespace *v1.Namespace, patch func(item interface{}) error, files ...string) error
CreateFromManifests is a combination of LoadFromManifests, PatchItems, patching with an optional custom function, and CreateItems.
func CreateItems(ctx context.Context, f *framework.Framework, ns *v1.Namespace, items ...interface{}) error
CreateItems creates the items. Each of them must be an API object of a type that is registered in Factory.
It returns either a cleanup function or an error, but never both.
Cleaning up after a test can be triggered in two ways:
PatchItems has the some limitations as LoadFromManifests: - only some common items are supported, unknown ones trigger an error - only the latest stable API version for each item is supported
func CreateVolumeSource(pvcName string, readOnly bool) *v1.VolumeSource
CreateVolumeSource creates a volume source object
func DeleteAndWaitSnapshot(ctx context.Context, dc dynamic.Interface, ns string, snapshotName string, poll, timeout time.Duration) error
DeleteAndWaitSnapshot deletes a VolumeSnapshot and waits for it to be deleted or until timeout occurs, whichever comes first
func DeleteSnapshotWithoutWaiting(ctx context.Context, dc dynamic.Interface, ns string, snapshotName string) error
DeleteSnapshotWithoutWaiting deletes a VolumeSnapshot and return directly without waiting
func DeleteStorageClass(ctx context.Context, cs clientset.Interface, className string) error
DeleteStorageClass deletes the passed in StorageClass and catches errors other than "Not Found"
func FindVolumeGlobalMountPoints(ctx context.Context, hostExec HostExec, node *v1.Node) sets.String
FindVolumeGlobalMountPoints returns all volume global mount points on the node of given pod.
func GenerateSnapshotClassSpec( snapshotter string, parameters map[string]string, ns string, ) *unstructured.Unstructured
GenerateSnapshotClassSpec constructs a new SnapshotClass instance spec with a unique name that is based on namespace + suffix.
func GetSectorSize(f *framework.Framework, pod *v1.Pod, device string) int
GetSectorSize returns the sector size of the device.
func GetSizeRangesIntersection(first e2evolume.SizeRange, second e2evolume.SizeRange) (string, error)
GetSizeRangesIntersection takes two instances of storage size ranges and determines the intersection of the intervals (if it exists) and return the minimum of the intersection to be used as the claim size for the test. if value not set, that means there's no minimum or maximum size limitation and we set default size for it.
func GetSnapshotContentFromSnapshot(ctx context.Context, dc dynamic.Interface, snapshot *unstructured.Unstructured, timeout time.Duration) *unstructured.Unstructured
GetSnapshotContentFromSnapshot returns the VolumeSnapshotContent object Bound to a given VolumeSnapshot
func KubeletCommand(ctx context.Context, kOp KubeletOpt, c clientset.Interface, pod *v1.Pod)
KubeletCommand performs `start`, `restart`, or `stop` on the kubelet running on the node of the target pod and waits for the desired statues.. - First issues the command via `systemctl` - If `systemctl` returns stderr "command not found, issues the command via `service` - If `service` also returns stderr "command not found", the test is aborted. Allowed kubeletOps are `KStart`, `KStop`, and `KRestart`
func LoadFromManifests(files ...string) ([]interface{}, error)
LoadFromManifests loads .yaml or .json manifest files and returns all items that it finds in them. It supports all items for which there is a factory registered in factories and .yaml files with multiple items separated by "---". Files are accessed via the "testfiles" package, which means they can come from a file system or be built into the binary.
LoadFromManifests has some limitations:
func LogResult(result Result)
LogResult records result log
func PatchCSIDeployment(f *e2eframework.Framework, o PatchCSIOptions, object interface{}) error
PatchCSIDeployment modifies the CSI driver deployment: - replaces the provisioner name - forces pods onto a specific host
All of that is optional, see PatchCSIOptions. Just beware that not renaming the CSI driver deployment can be problematic:
This function is written so that it works for CSI driver deployments that follow these conventions:
Driver deployments that are different will have to do the patching without this function, or skip patching entirely.
func PatchItems(f *framework.Framework, driverNamespace *v1.Namespace, items ...interface{}) error
PatchItems modifies the given items in place such that each test gets its own instances, to avoid conflicts between different tests and between tests and normal deployments.
This is done by: - creating namespaced items inside the test's namespace - changing the name of non-namespaced items like ClusterRole
PatchItems has some limitations: - only some common items are supported, unknown ones trigger an error - only the latest stable API version for each item is supported
func PatchName(f *framework.Framework, item *string)
PatchName makes the name of some item unique by appending the generated unique name.
func PatchNamespace(f *framework.Framework, driverNamespace *v1.Namespace, item *string)
PatchNamespace moves the item into the test's namespace. Not all items can be namespaced. For those, the name also needs to be patched.
func PrettyPrint(item interface{}) string
PrettyPrint returns a human-readable representation of an item.
func RunInPodWithVolume(ctx context.Context, c clientset.Interface, t *framework.TimeoutContext, ns, claimName, command string)
RunInPodWithVolume runs a command in a pod with given claim mounted to /mnt directory.
func StartExternalProvisioner(ctx context.Context, c clientset.Interface, ns string, externalPluginName string) *v1.Pod
StartExternalProvisioner create external provisioner pod
func StartPodLogs(ctx context.Context, f *framework.Framework, driverNamespace *v1.Namespace) func()
StartPodLogs begins capturing log output and events from current and future pods running in the namespace of the framework. That ends when the returned cleanup function is called.
The output goes to log files (when using --report-dir, as in the CI) or the output stream (otherwise).
func TestKubeletRestartsAndRestoresMap(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, volumePath string)
TestKubeletRestartsAndRestoresMap tests that a volume mapped to a pod remains mapped after a kubelet restarts
func TestKubeletRestartsAndRestoresMount(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, volumePath string)
TestKubeletRestartsAndRestoresMount tests that a volume mounted to a pod remains mounted after a kubelet restarts
func TestVolumeUnmapsFromDeletedPod(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, devicePath string)
TestVolumeUnmapsFromDeletedPod tests that a volume unmaps if the client pod was deleted while the kubelet was down.
func TestVolumeUnmapsFromDeletedPodWithForceOption(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, forceDelete bool, devicePath string)
TestVolumeUnmapsFromDeletedPodWithForceOption tests that a volume unmaps if the client pod was deleted while the kubelet was down. forceDelete is true indicating whether the pod is forcefully deleted.
func TestVolumeUnmapsFromForceDeletedPod(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, devicePath string)
TestVolumeUnmapsFromForceDeletedPod tests that a volume unmaps if the client pod was forcefully deleted while the kubelet was down.
func TestVolumeUnmountsFromDeletedPod(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, volumePath string)
TestVolumeUnmountsFromDeletedPod tests that a volume unmounts if the client pod was deleted while the kubelet was down.
func TestVolumeUnmountsFromDeletedPodWithForceOption(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, forceDelete bool, checkSubpath bool, secondPod *v1.Pod, volumePath string)
TestVolumeUnmountsFromDeletedPodWithForceOption tests that a volume unmounts if the client pod was deleted while the kubelet was down. forceDelete is true indicating whether the pod is forcefully deleted. checkSubpath is true indicating whether the subpath should be checked. If secondPod is set, it is started when kubelet is down to check that the volume is usable while the old pod is being deleted and the new pod is starting.
func TestVolumeUnmountsFromForceDeletedPod(ctx context.Context, c clientset.Interface, f *framework.Framework, clientPod *v1.Pod, volumePath string)
TestVolumeUnmountsFromForceDeletedPod tests that a volume unmounts if the client pod was forcefully deleted while the kubelet was down.
func TryFunc(f func()) error
TryFunc try to execute the function and return err if there is any
func VerifyFSGroupInPod(f *framework.Framework, filePath, expectedFSGroup string, pod *v1.Pod)
VerifyFSGroupInPod verifies that the passed in filePath contains the expectedFSGroup
func VerifyFilePathGidInPod(f *framework.Framework, filePath, expectedGid string, pod *v1.Pod)
VerifyFilePathGidInPod verfies expected GID of the target filepath
func WaitForGVRDeletion(ctx context.Context, c dynamic.Interface, gvr schema.GroupVersionResource, objectName string, poll, timeout time.Duration) error
WaitForGVRDeletion waits until a non-namespaced object has been deleted
func WaitForGVRFinalizer(ctx context.Context, c dynamic.Interface, gvr schema.GroupVersionResource, objectName, objectNamespace, finalizer string, poll, timeout time.Duration) error
WaitForGVRFinalizer waits until a object from a given GVR contains a finalizer If namespace is empty, assume it is a non-namespaced object
func WaitForNamespacedGVRDeletion(ctx context.Context, c dynamic.Interface, gvr schema.GroupVersionResource, ns, objectName string, poll, timeout time.Duration) error
WaitForNamespacedGVRDeletion waits until a namespaced object has been deleted
func WaitForSnapshotReady(ctx context.Context, c dynamic.Interface, ns string, snapshotName string, poll, timeout time.Duration) error
WaitForSnapshotReady waits for a VolumeSnapshot to be ready to use or until timeout occurs, whichever comes first.
func WaitUntil(poll, timeout time.Duration, checkDone func() bool) bool
WaitUntil runs checkDone until a timeout is reached
HostExec represents interface we require to execute commands on remote host.
type HostExec interface { Execute(ctx context.Context, cmd string, node *v1.Node) (Result, error) IssueCommandWithResult(ctx context.Context, cmd string, node *v1.Node) (string, error) IssueCommand(ctx context.Context, cmd string, node *v1.Node) error Cleanup(ctx context.Context) }
func NewHostExec(framework *framework.Framework) HostExec
NewHostExec returns a HostExec
ItemFactory provides support for creating one particular item. The type gets exported because other packages might want to extend the set of pre-defined factories.
type ItemFactory interface { // New returns a new empty item. New() runtime.Object // Create is responsible for creating the item. It returns an // error or a cleanup function for the created item. // If the item is of an unsupported type, it must return // an error that has errorItemNotSupported as cause. Create(ctx context.Context, f *framework.Framework, ns *v1.Namespace, item interface{}) (func(ctx context.Context) error, error) }
KubeletOpt type definition
type KubeletOpt string
const ( // NodeStateTimeout defines Timeout NodeStateTimeout = 1 * time.Minute // KStart defines start value KStart KubeletOpt = "start" // KStop defines stop value KStop KubeletOpt = "stop" // KRestart defines restart value KRestart KubeletOpt = "restart" )
LocalTestResource represents test resource of a local volume.
type LocalTestResource struct { VolumeType LocalVolumeType Node *v1.Node // Volume path, path to filesystem or block device on the node Path string // contains filtered or unexported fields }
LocalTestResourceManager represents interface to create/destroy local test resources on node
type LocalTestResourceManager interface { Create(ctx context.Context, node *v1.Node, volumeType LocalVolumeType, parameters map[string]string) *LocalTestResource ExpandBlockDevice(ctx context.Context, ltr *LocalTestResource, mbToAdd int) error Remove(ctx context.Context, ltr *LocalTestResource) }
func NewLocalResourceManager(prefix string, hostExec HostExec, hostBase string) LocalTestResourceManager
NewLocalResourceManager returns a instance of LocalTestResourceManager
LocalVolumeType represents type of local volume, e.g. tmpfs, directory, block, etc.
type LocalVolumeType string
const ( // LocalVolumeDirectory reprensents a simple directory as local volume LocalVolumeDirectory LocalVolumeType = "dir" // LocalVolumeDirectoryLink is like LocalVolumeDirectory but it's a symbolic link to directory LocalVolumeDirectoryLink LocalVolumeType = "dir-link" // LocalVolumeDirectoryBindMounted is like LocalVolumeDirectory but bind mounted LocalVolumeDirectoryBindMounted LocalVolumeType = "dir-bindmounted" // LocalVolumeDirectoryLinkBindMounted is like LocalVolumeDirectory but it's a symbolic link to self bind mounted directory // Note that bind mounting at symbolic link actually mounts at directory it // links to LocalVolumeDirectoryLinkBindMounted LocalVolumeType = "dir-link-bindmounted" // LocalVolumeTmpfs represents a temporary filesystem to be used as local volume LocalVolumeTmpfs LocalVolumeType = "tmpfs" // LocalVolumeBlock represents a Block device, creates a local file, and maps it as a block device LocalVolumeBlock LocalVolumeType = "block" // LocalVolumeBlockFS represents a filesystem backed by a block device LocalVolumeBlockFS LocalVolumeType = "blockfs" // LocalVolumeGCELocalSSD represents a Filesystem backed by GCE Local SSD as local volume LocalVolumeGCELocalSSD LocalVolumeType = "gce-localssd-scsi-fs" )
PatchCSIOptions controls how PatchCSIDeployment patches the objects.
type PatchCSIOptions struct { // The original driver name. OldDriverName string // The driver name that replaces the original name. // Can be empty (not used at all) or equal to OldDriverName // (then it will be added were appropriate without renaming // in existing fields). NewDriverName string // The name of the container which has the CSI driver binary. // If non-empty, DriverContainerArguments are added to argument // list in container with that name. DriverContainerName string // List of arguments to add to container with // DriverContainerName. DriverContainerArguments []string // The name of the container which has the provisioner binary. // If non-empty, --provisioner with new name will be appended // to the argument list. ProvisionerContainerName string // The name of the container which has the snapshotter binary. // If non-empty, --snapshotter with new name will be appended // to the argument list. SnapshotterContainerName string // If non-empty, all pods are forced to run on this node. NodeName string // If not nil, the value to use for the CSIDriver.Spec.PodInfo // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. PodInfo *bool // If not nil, the value to use for the CSIDriver.Spec.CanAttach // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. CanAttach *bool // If not nil, the value to use for the CSIDriver.Spec.StorageCapacity // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. StorageCapacity *bool // If not nil, the value to use for the CSIDriver.Spec.VolumeLifecycleModes // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. VolumeLifecycleModes *[]storagev1.VolumeLifecycleMode // If not nil, the value to use for the CSIDriver.Spec.TokenRequests // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. TokenRequests []storagev1.TokenRequest // If not nil, the value to use for the CSIDriver.Spec.RequiresRepublish // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. RequiresRepublish *bool // If not nil, the value to use for the CSIDriver.Spec.FSGroupPolicy // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. FSGroupPolicy *storagev1.FSGroupPolicy // If not nil, the value to use for the CSIDriver.Spec.SELinuxMount // field *if* the driver deploys a CSIDriver object. Ignored // otherwise. SELinuxMount *bool // If not nil, the values will be used for setting feature arguments to // specific sidecar. // Feature is a map - where key is sidecar name such as: // -- key: resizer // -- value: []string{feature-gates} Features map[string][]string }
Result holds the execution result of remote execution command.
type Result struct { Host string Cmd string Stdout string Stderr string Code int }
What is a subset of metav1.TypeMeta which (in contrast to metav1.TypeMeta itself) satisfies the runtime.Object interface.
type What struct { Kind string `json:"kind"` }
func (in *What) DeepCopy() *What
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new What.
func (in *What) DeepCopyInto(out *What)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out.
func (in *What) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *What) GetObjectKind() schema.ObjectKind
GetObjectKind returns the ObjectKind schema