Documentation ¶
Index ¶
- Constants
- func DeleteNS(c *kubernetes.Clientset, ns string) error
- func GetKubeClientFromRESTConfig(config *rest.Config) (*kubernetes.Clientset, error)
- func VerifyPVCIsEmpty(f *Framework, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
- type Config
- type ExecOptions
- type Framework
- func (f *Framework) AddNamespaceToDelete(ns *v1.Namespace)
- func (f *Framework) AfterEach()
- func (f *Framework) BeforeEach()
- func (f *Framework) CreateAndPopulateSourcePVC(pvcDef *k8sv1.PersistentVolumeClaim, podName string, fillCommand string) *k8sv1.PersistentVolumeClaim
- func (f *Framework) CreateExecutorPodWithPVC(podName string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error)
- func (f *Framework) CreateNamespace(prefix string, labels map[string]string) (*v1.Namespace, error)
- func (f *Framework) CreatePVCFromDefinition(def *k8sv1.PersistentVolumeClaim) (*k8sv1.PersistentVolumeClaim, error)
- func (f *Framework) CreatePVFromDefinition(def *k8sv1.PersistentVolume) (*k8sv1.PersistentVolume, error)
- func (f *Framework) CreatePod(podDef *k8sv1.Pod) (*k8sv1.Pod, error)
- func (f *Framework) CreatePrometheusServiceInNs(namespace string) (*v1.Service, error)
- func (f *Framework) DeletePVC(pvc *k8sv1.PersistentVolumeClaim) error
- func (f *Framework) DeletePod(pod *k8sv1.Pod) error
- func (f *Framework) ExecCommandInContainer(namespace, podName, containerName string, cmd ...string) (string, error)
- func (f *Framework) ExecCommandInContainerWithFullOutput(namespace, podName, containerName string, cmd ...string) (string, string, error)
- func (f *Framework) ExecCommandInPod(podName, namespace string, cmd ...string) (string, error)
- func (f *Framework) ExecCommandInPodWithFullOutput(namespace, podName string, cmd ...string) (string, string, error)
- func (f *Framework) ExecShellInContainer(podName, containerName string, cmd string) (string, error)
- func (f *Framework) ExecShellInPod(podName, namespace string, cmd string) (string, error)
- func (f *Framework) ExecShellInPodWithFullOutput(podName string, cmd string) (string, string, error)
- func (f *Framework) ExecWithOptions(options ExecOptions) (string, string, error)
- func (f *Framework) FindPVC(pvcName string) (*k8sv1.PersistentVolumeClaim, error)
- func (f *Framework) FindPodByPrefix(prefix string) (*k8sv1.Pod, error)
- func (f *Framework) GetCdiClient() (*cdiClientset.Clientset, error)
- func (f *Framework) GetCdiClientForServiceAccount(namespace, name string) (*cdiClientset.Clientset, error)
- func (f *Framework) GetKubeClient() (*kubernetes.Clientset, error)
- func (f *Framework) GetMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, ...) (string, error)
- func (f *Framework) IsBlockVolumeStorageClassAvailable() bool
- func (f *Framework) IsSnapshotStorageClassAvailable() bool
- func (f *Framework) LoadConfig() (*rest.Config, error)
- func (f *Framework) RunCommandAndCaptureOutput(pvc *k8sv1.PersistentVolumeClaim, cmd string) (string, error)
- func (f *Framework) VerifyBlankDisk(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
- func (f *Framework) VerifyNotSparse(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
- func (f *Framework) VerifyTargetPVCArchiveContent(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, count string) (bool, error)
- func (f *Framework) VerifyTargetPVCContent(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, ...) (bool, error)
- func (f *Framework) VerifyTargetPVCContentMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, ...) (bool, error)
- func (f *Framework) WaitForPersistentVolumeClaimPhase(phase k8sv1.PersistentVolumeClaimPhase, pvcName string) error
- func (f *Framework) WaitTimeoutForPVReady(pvName string, timeout time.Duration) error
- func (f *Framework) WaitTimeoutForPodReady(podName string, timeout time.Duration) error
- func (f *Framework) WaitTimeoutForPodStatus(podName string, status k8sv1.PodPhase, timeout time.Duration) error
Constants ¶
const (
//NsPrefixLabel provides a cdi prefix label to identify the test namespace
NsPrefixLabel = "cdi-e2e"
)
Variables ¶
This section is empty.
Functions ¶
func DeleteNS ¶
func DeleteNS(c *kubernetes.Clientset, ns string) error
DeleteNS provides a function to delete the specified namespace from the test cluster
func GetKubeClientFromRESTConfig ¶
func GetKubeClientFromRESTConfig(config *rest.Config) (*kubernetes.Clientset, error)
GetKubeClientFromRESTConfig provides a function to get a K8s client using hte REST config
func VerifyPVCIsEmpty ¶
func VerifyPVCIsEmpty(f *Framework, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
VerifyPVCIsEmpty verifies a passed in PVC is empty, returns true if the PVC is empty, false if it is not.
Types ¶
type Config ¶
type Config struct { // SkipNamespaceCreation sets whether to skip creating a namespace. Use this ONLY for tests that do not require // a namespace at all, like basic sanity or other global tests. SkipNamespaceCreation bool // SkipControllerPodLookup sets whether to skip looking up the name of the cdi controller pod. SkipControllerPodLookup bool }
Config provides some basic test config options
type ExecOptions ¶
type ExecOptions struct { Command []string Namespace string PodName string ContainerName string Stdin io.Reader CaptureStdout bool CaptureStderr bool // If false, whitespace in std{err,out} will be removed. PreserveWhitespace bool }
ExecOptions passed to ExecWithOptions
type Framework ¶
type Framework struct { Config // NsPrefix is a prefix for generated namespace NsPrefix string // k8sClient provides our k8s client pointer K8sClient *kubernetes.Clientset // CdiClient provides our CDI client pointer CdiClient *cdiClientset.Clientset // RestConfig provides a pointer to our REST client config. RestConfig *rest.Config // Namespace provides a namespace for each test generated/unique ns per test Namespace *v1.Namespace // Namespace2 provides an additional generated/unique secondary ns for testing across namespaces (eg. clone tests) Namespace2 *v1.Namespace // note: not instantiated in NewFramework // ControllerPod provides a pointer to our test controller pod ControllerPod *v1.Pod // KubectlPath is a test run-time flag so we can find kubectl KubectlPath string // OcPath is a test run-time flag so we can find OpenShift Client OcPath string // CdiInstallNs is a test run-time flag to store the Namespace we installed CDI in CdiInstallNs string // KubeConfig is a test run-time flag to store the location of our test setup kubeconfig KubeConfig string // Master is a test run-time flag to store the id of our master node Master string // GoCliPath is a test run-time flag to store the location of gocli GoCLIPath string // SnapshotSCName is the Storage Class name that supports Snapshots SnapshotSCName string // BlockSCName is the Storage Class name that supports block mode BlockSCName string // contains filtered or unexported fields }
Framework supports common operations used by functional/e2e tests. It holds the k8s and cdi clients, a generated unique namespace, run-time flags, and more fields will be added over time as cdi e2e evolves. Global BeforeEach and AfterEach are called in the Framework constructor.
func NewFramework ¶
NewFramework makes a new framework and sets up the global BeforeEach/AfterEach's. Test run-time flags are parsed and added to the Framework struct.
func NewFrameworkOrDie ¶
NewFrameworkOrDie calls NewFramework and handles errors by calling Fail. Config is optional, but if passed there can only be one.
func (*Framework) AddNamespaceToDelete ¶
AddNamespaceToDelete provides a wrapper around the go append function
func (*Framework) AfterEach ¶
func (f *Framework) AfterEach()
AfterEach provides a set of operations to run after each test
func (*Framework) BeforeEach ¶
func (f *Framework) BeforeEach()
BeforeEach provides a set of operations to run before each test
func (*Framework) CreateAndPopulateSourcePVC ¶
func (f *Framework) CreateAndPopulateSourcePVC(pvcDef *k8sv1.PersistentVolumeClaim, podName string, fillCommand string) *k8sv1.PersistentVolumeClaim
CreateAndPopulateSourcePVC Creates and populates a PVC using the provided POD and command
func (*Framework) CreateExecutorPodWithPVC ¶
func (f *Framework) CreateExecutorPodWithPVC(podName string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error)
CreateExecutorPodWithPVC is a wrapper around utils.CreateExecutorPodWithPVC
func (*Framework) CreateNamespace ¶
CreateNamespace instantiates a new namespace object with a unique name and the passed-in label(s).
func (*Framework) CreatePVCFromDefinition ¶
func (f *Framework) CreatePVCFromDefinition(def *k8sv1.PersistentVolumeClaim) (*k8sv1.PersistentVolumeClaim, error)
CreatePVCFromDefinition is a wrapper around utils.CreatePVCFromDefinition
func (*Framework) CreatePVFromDefinition ¶ added in v1.5.0
func (f *Framework) CreatePVFromDefinition(def *k8sv1.PersistentVolume) (*k8sv1.PersistentVolume, error)
CreatePVFromDefinition is a wrapper around utils.CreatePVFromDefinition
func (*Framework) CreatePrometheusServiceInNs ¶ added in v1.4.0
CreatePrometheusServiceInNs creates a service for prometheus in the specified namespace. This allows us to test for prometheus end points using the service to connect to the endpoints.
func (*Framework) DeletePVC ¶
func (f *Framework) DeletePVC(pvc *k8sv1.PersistentVolumeClaim) error
DeletePVC is a wrapper around utils.DeletePVC
func (*Framework) ExecCommandInContainer ¶
func (f *Framework) ExecCommandInContainer(namespace, podName, containerName string, cmd ...string) (string, error)
ExecCommandInContainer executes a command in the specified container.
func (*Framework) ExecCommandInContainerWithFullOutput ¶
func (f *Framework) ExecCommandInContainerWithFullOutput(namespace, podName, containerName string, cmd ...string) (string, string, error)
ExecCommandInContainerWithFullOutput executes a command in the specified container and return stdout, stderr and error
func (*Framework) ExecCommandInPod ¶
ExecCommandInPod provides a function to execute a command on a running pod
func (*Framework) ExecCommandInPodWithFullOutput ¶
func (f *Framework) ExecCommandInPodWithFullOutput(namespace, podName string, cmd ...string) (string, string, error)
ExecCommandInPodWithFullOutput provides a function to execute a command in a running pod and to capture its output
func (*Framework) ExecShellInContainer ¶
ExecShellInContainer provides a function to execute a shell cmd for the specified running container in a pod
func (*Framework) ExecShellInPod ¶
ExecShellInPod provides a function to execute a shell cmd in the specified pod
func (*Framework) ExecShellInPodWithFullOutput ¶
func (f *Framework) ExecShellInPodWithFullOutput(podName string, cmd string) (string, string, error)
ExecShellInPodWithFullOutput provides a function to execute a shell cmd in a running pod and to capture its output
func (*Framework) ExecWithOptions ¶
func (f *Framework) ExecWithOptions(options ExecOptions) (string, string, error)
ExecWithOptions executes a command in the specified container, returning stdout, stderr and error. `options` allowed for additional parameters to be passed.
func (*Framework) FindPVC ¶
func (f *Framework) FindPVC(pvcName string) (*k8sv1.PersistentVolumeClaim, error)
FindPVC is a wrapper around utils.FindPVC
func (*Framework) FindPodByPrefix ¶
FindPodByPrefix is a wrapper around utils.FindPodByPrefix
func (*Framework) GetCdiClient ¶
func (f *Framework) GetCdiClient() (*cdiClientset.Clientset, error)
GetCdiClient gets an instance of a kubernetes client that includes all the CDI extensions.
func (*Framework) GetCdiClientForServiceAccount ¶ added in v1.9.4
func (f *Framework) GetCdiClientForServiceAccount(namespace, name string) (*cdiClientset.Clientset, error)
GetCdiClientForServiceAccount returns a cdi client for a service account
func (*Framework) GetKubeClient ¶
func (f *Framework) GetKubeClient() (*kubernetes.Clientset, error)
GetKubeClient returns a Kubernetes rest client
func (*Framework) GetMD5 ¶ added in v1.9.4
func (f *Framework) GetMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, numBytes int64) (string, error)
GetMD5 returns the MD5 of a file on a PVC
func (*Framework) IsBlockVolumeStorageClassAvailable ¶ added in v1.10.0
IsBlockVolumeStorageClassAvailable checks if the block volume storage class exists.
func (*Framework) IsSnapshotStorageClassAvailable ¶ added in v1.10.0
IsSnapshotStorageClassAvailable checks if the snapshot storage class exists.
func (*Framework) LoadConfig ¶
LoadConfig loads our specified kubeconfig
func (*Framework) RunCommandAndCaptureOutput ¶ added in v1.7.0
func (f *Framework) RunCommandAndCaptureOutput(pvc *k8sv1.PersistentVolumeClaim, cmd string) (string, error)
RunCommandAndCaptureOutput runs a command on a pod that has the passed in PVC mounted and captures the output.
func (*Framework) VerifyBlankDisk ¶ added in v1.10.5
func (f *Framework) VerifyBlankDisk(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
VerifyBlankDisk checks a blank disk on a file mode PVC by validating that the disk.img file is sparse.
func (*Framework) VerifyNotSparse ¶ added in v1.10.9
func (f *Framework) VerifyNotSparse(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
VerifyNotSparse checks a disk image not being sparse after creation/resize.
func (*Framework) VerifyTargetPVCArchiveContent ¶ added in v1.10.0
func (f *Framework) VerifyTargetPVCArchiveContent(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, count string) (bool, error)
VerifyTargetPVCArchiveContent provides a function to check if the number of files extracted from an archive matches the passed in value
func (*Framework) VerifyTargetPVCContent ¶
func (f *Framework) VerifyTargetPVCContent(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, expectedData, testBaseDir, testFile string) (bool, error)
VerifyTargetPVCContent is used to check the contents of a PVC and ensure it matches the provided expected data
func (*Framework) VerifyTargetPVCContentMD5 ¶
func (f *Framework) VerifyTargetPVCContentMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, expectedHash string, numBytes ...int64) (bool, error)
VerifyTargetPVCContentMD5 provides a function to check the md5 of data on a PVC and ensure it matches that which is provided
func (*Framework) WaitForPersistentVolumeClaimPhase ¶
func (f *Framework) WaitForPersistentVolumeClaimPhase(phase k8sv1.PersistentVolumeClaimPhase, pvcName string) error
WaitForPersistentVolumeClaimPhase is a wrapper around utils.WaitForPersistentVolumeClaimPhase
func (*Framework) WaitTimeoutForPVReady ¶ added in v1.5.0
WaitTimeoutForPVReady is a wrapper around utils.WaitTimeouotForPVReady
func (*Framework) WaitTimeoutForPodReady ¶
WaitTimeoutForPodReady is a wrapper around utils.WaitTimeouotForPodReady