volume

package
v1.16.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Kb is byte size of kilobyte
	Kb int64 = 1000
	// Mb is byte size of megabyte
	Mb int64 = 1000 * Kb
	// Gb is byte size of gigabyte
	Gb int64 = 1000 * Mb
	// Tb is byte size of terabyte
	Tb int64 = 1000 * Gb
	// KiB is byte size of kibibyte
	KiB int64 = 1024
	// MiB is byte size of mebibyte
	MiB int64 = 1024 * KiB
	// GiB is byte size of gibibyte
	GiB int64 = 1024 * MiB
	// TiB is byte size of tebibyte
	TiB int64 = 1024 * GiB

	// VolumeServerPodStartupTimeout is a waiting period for volume server (Ceph, ...) to initialize itself.
	VolumeServerPodStartupTimeout = 3 * time.Minute

	// PodCleanupTimeout is a waiting period for pod to be cleaned up and unmount its volumes so we
	// don't tear down containers with NFS/Ceph/Gluster server too early.
	PodCleanupTimeout = 20 * time.Second
)

Variables

This section is empty.

Functions

func CleanUpVolumeServer

func CleanUpVolumeServer(f *framework.Framework, serverPod *v1.Pod)

CleanUpVolumeServer is a wrapper of cleanup function for volume server without secret created by specific CreateStorageServer function.

func CleanUpVolumeServerWithSecret

func CleanUpVolumeServerWithSecret(f *framework.Framework, serverPod *v1.Pod, secret *v1.Secret)

CleanUpVolumeServerWithSecret is a wrapper of cleanup function for volume server with secret created by specific CreateStorageServer function.

func CreateGCEVolume

func CreateGCEVolume() (*v1.PersistentVolumeSource, string)

CreateGCEVolume creates PersistentVolumeSource for GCEVolume.

func CreateStorageServer

func CreateStorageServer(cs clientset.Interface, config TestConfig) (pod *v1.Pod, ip string)

CreateStorageServer is a wrapper for StartVolumeServer(). A storage server config is passed in, and a pod pointer and ip address string are returned. Note: Expect() is called so no error is returned.

func GeneratePodSecurityContext

func GeneratePodSecurityContext(fsGroup *int64, seLinuxOptions *v1.SELinuxOptions) *v1.PodSecurityContext

GeneratePodSecurityContext generates the corresponding pod security context with the given inputs If the Node OS is windows, currently we will ignore the inputs and return nil. TODO: Will modify it after windows has its own security context

func GenerateReadBlockCmd

func GenerateReadBlockCmd(fullPath string, numberOfCharacters int) []string

GenerateReadBlockCmd generates the corresponding command lines to read from a block device with the given file path. Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh

func GenerateReadFileCmd

func GenerateReadFileCmd(fullPath string) []string

GenerateReadFileCmd generates the corresponding command lines to read from a file with the given file path. Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh

func GenerateScriptCmd

func GenerateScriptCmd(command string) []string

GenerateScriptCmd generates the corresponding command lines to execute a command. Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh

func GenerateSecurityContext

func GenerateSecurityContext(privileged bool) *v1.SecurityContext

GenerateSecurityContext generates the corresponding container security context with the given inputs If the Node OS is windows, currently we will ignore the inputs and return nil. TODO: Will modify it after windows has its own security context

func GenerateWriteBlockCmd

func GenerateWriteBlockCmd(content, fullPath string) []string

GenerateWriteBlockCmd generates the corresponding command lines to write to a block device the given content. Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh

func GenerateWriteFileCmd

func GenerateWriteFileCmd(content, fullPath string) []string

GenerateWriteFileCmd generates the corresponding command lines to write a file with the given content and file path. Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh

func GenerateWriteandExecuteScriptFileCmd

func GenerateWriteandExecuteScriptFileCmd(content, fileName, filePath string) []string

GenerateWriteandExecuteScriptFileCmd generates the corresponding command lines to write a file with the given file path and also execute this file. Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh

func GetTestImage

func GetTestImage(image string) string

GetTestImage returns the image name with the given input If the Node OS is windows, currently we return Agnhost image for Windows node due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.

func InjectContent

func InjectContent(client clientset.Interface, config TestConfig, fsGroup *int64, fsType string, tests []Test)

InjectContent inserts index.html with given content into given volume. It does so by starting and auxiliary pod which writes the file there. The volume must be writable.

func StartVolumeServer

func StartVolumeServer(client clientset.Interface, config TestConfig) *v1.Pod

StartVolumeServer starts a container specified by config.serverImage and exports all config.serverPorts from it. The returned pod should be used to get the server IP address and create appropriate VolumeSource.

func TestCleanup

func TestCleanup(f *framework.Framework, config TestConfig)

TestCleanup cleans both server and client pods.

func TestVolumeClient

func TestVolumeClient(client clientset.Interface, config TestConfig, fsGroup *int64, fsType string, tests []Test)

TestVolumeClient start a client pod using given VolumeSource (exported by startVolumeServer()) and check that the pod sees expected data, e.g. from the server pod. Multiple Tests can be specified to mount multiple volumes to a single pod.

Types

type Test

type Test struct {
	Volume v1.VolumeSource
	Mode   v1.PersistentVolumeMode
	// Name of file to read/write in FileSystem mode
	File            string
	ExpectedContent string
}

Test contains a volume to mount into a client pod and its expected content.

type TestConfig

type TestConfig struct {
	Namespace string
	// Prefix of all pods. Typically the test name.
	Prefix string
	// Name of container image for the server pod.
	ServerImage string
	// Ports to export from the server pod. TCP only.
	ServerPorts []int
	// Commands to run in the container image.
	ServerCmds []string
	// Arguments to pass to the container image.
	ServerArgs []string
	// Volumes needed to be mounted to the server container from the host
	// map <host (source) path> -> <container (dst.) path>
	// if <host (source) path> is empty, mount a tmpfs emptydir
	ServerVolumes map[string]string
	// Message to wait for before starting clients
	ServerReadyMessage string
	// Use HostNetwork for the server
	ServerHostNetwork bool
	// Wait for the pod to terminate successfully
	// False indicates that the pod is long running
	WaitForCompletion bool
	// ServerNodeName is the spec.nodeName to run server pod on.  Default is any node.
	ServerNodeName string
	// ClientNodeName is the spec.nodeName to run client pod on.  Default is any node.
	ClientNodeName string
	// NodeSelector to use in pod spec (server, client and injector pods).
	NodeSelector map[string]string
}

TestConfig is a struct for configuration of one tests. The test consist of: - server pod - runs serverImage, exports ports[] - client pod - does not need any special configuration

func NewGlusterfsServer

func NewGlusterfsServer(cs clientset.Interface, namespace string) (config TestConfig, pod *v1.Pod, ip string)

NewGlusterfsServer is a GlusterFS-specific wrapper for CreateStorageServer. Also creates the gluster endpoints object.

func NewISCSIServer

func NewISCSIServer(cs clientset.Interface, namespace string) (config TestConfig, pod *v1.Pod, ip, iqn string)

NewISCSIServer is an iSCSI-specific wrapper for CreateStorageServer.

func NewNFSServer

func NewNFSServer(cs clientset.Interface, namespace string, args []string) (config TestConfig, pod *v1.Pod, ip string)

NewNFSServer is a NFS-specific wrapper for CreateStorageServer.

func NewRBDServer

func NewRBDServer(cs clientset.Interface, namespace string) (config TestConfig, pod *v1.Pod, secret *v1.Secret, ip string)

NewRBDServer is a CephRBD-specific wrapper for CreateStorageServer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL