Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteNS(c *kubernetes.Clientset, ns string) error
- func GetKubeClientFromRESTConfig(config *rest.Config) (*kubernetes.Clientset, error)
- func VerifyPVCIsEmpty(f *Framework, pvc *k8sv1.PersistentVolumeClaim, node string) (bool, error)
- type Clients
- func (c *Clients) GetCdiClient() (*cdiClientset.Clientset, error)
- func (c *Clients) GetCrClient() (crclient.Client, error)
- func (c *Clients) GetExtClient() (*extclientset.Clientset, error)
- func (c *Clients) GetKubeClient() (*kubernetes.Clientset, error)
- func (c *Clients) LoadConfig() (*rest.Config, 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) CreateBoundPVCFromDefinition(def *k8sv1.PersistentVolumeClaim) (*k8sv1.PersistentVolumeClaim, error)
- func (f *Framework) CreateExecutorPodWithPVC(podName, namespace string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error)
- func (f *Framework) CreateExecutorPodWithPVCSpecificNode(podName, namespace string, pvc *k8sv1.PersistentVolumeClaim, node string) (*k8sv1.Pod, error)
- func (f *Framework) CreateNamespace(prefix string, labels map[string]string) (*v1.Namespace, error)
- func (f *Framework) CreateNoopPodWithPVC(podName, namespace string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, 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) CreateQuotaInNs(requestCPU, requestMemory, limitsCPU, limitsMemory int64) error
- func (f *Framework) CreateQuotaInSpecifiedNs(ns string, requestCPU, requestMemory, limitsCPU, limitsMemory int64) error
- func (f *Framework) CreateVerifierPodWithPVC(namespace string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, 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, 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, string, error)
- func (f *Framework) ExecCommandInPodWithFullOutput(namespace, podName string, cmd ...string) (string, string, error)
- func (f *Framework) ExecShellInContainer(namespace, podName, containerName string, cmd string) (string, string, error)
- func (f *Framework) ExecShellInPod(podName, namespace string, cmd string) (string, string, error)
- func (f *Framework) ExecShellInPodWithFullOutput(namespace, 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) FindPodBySuffix(prefix string) (*k8sv1.Pod, error)
- func (f *Framework) ForceBindIfWaitForFirstConsumer(targetPvc *k8sv1.PersistentVolumeClaim)
- func (f *Framework) ForceBindPvcIfDvIsWaitForFirstConsumer(dv *cdiv1.DataVolume)
- func (f *Framework) GetCdiClientForServiceAccount(namespace, name string) (*cdiClientset.Clientset, error)
- func (f *Framework) GetDiskGroup(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, deletePod bool) (string, error)
- func (f *Framework) GetMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, ...) (string, error)
- func (f *Framework) GetRESTConfigForServiceAccount(namespace, name string) (*rest.Config, error)
- func (f *Framework) IsBindingModeWaitForFirstConsumer(storageClassName *string) bool
- func (f *Framework) IsBlockVolumeStorageClassAvailable() bool
- func (f *Framework) IsSnapshotStorageClassAvailable() bool
- func (f *Framework) NewPodWithPVC(podName, cmd string, pvc *k8sv1.PersistentVolumeClaim) *k8sv1.Pod
- func (f *Framework) RunCommandAndCaptureOutput(pvc *k8sv1.PersistentVolumeClaim, cmd string) (string, error)
- func (f *Framework) UpdateCdiConfigResourceLimits(resourceCPU, resourceMemory, limitsCPU, limitsMemory int64) error
- func (f *Framework) UpdateQuotaInNs(requestCPU, requestMemory, limitsCPU, limitsMemory int64) error
- func (f *Framework) VerifyBlankDisk(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
- func (f *Framework) VerifyPermissions(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
- func (f *Framework) VerifySparse(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) VerifyTargetPVCContentMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, ...) (bool, error)
- func (f *Framework) WaitForPersistentVolumeClaimPhase(phase k8sv1.PersistentVolumeClaimPhase, pvcName string) error
- func (f *Framework) WaitPVCDeletedByUID(pvcSpec *k8sv1.PersistentVolumeClaim, timeout time.Duration) (bool, 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
- type KubernetesReporter
Constants ¶
const (
//NsPrefixLabel provides a cdi prefix label to identify the test namespace
NsPrefixLabel = "cdi-e2e"
)
Variables ¶
var (
ClientsInstance = &Clients{}
)
run-time flags
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 ¶
VerifyPVCIsEmpty verifies a passed in PVC is empty, returns true if the PVC is empty, false if it is not. Optionaly, specify node for the pod.
Types ¶
type Clients ¶ added in v1.21.0
type Clients struct { KubectlPath string OcPath string CdiInstallNs string KubeConfig string Master string GoCLIPath string SnapshotSCName string BlockSCName string // k8sClient provides our k8s client pointer K8sClient *kubernetes.Clientset // CdiClient provides our CDI client pointer CdiClient *cdiClientset.Clientset // ExtClient provides our CSI client pointer ExtClient *extclientset.Clientset // CrClient is a controller runtime client CrClient crclient.Client // RestConfig provides a pointer to our REST client config. RestConfig *rest.Config }
Clients is the struct containing the client-go kubernetes clients
func (*Clients) GetCdiClient ¶ added in v1.21.0
func (c *Clients) GetCdiClient() (*cdiClientset.Clientset, error)
GetCdiClient gets an instance of a kubernetes client that includes all the CDI extensions.
func (*Clients) GetCrClient ¶ added in v1.21.0
GetCrClient returns a controller runtime client
func (*Clients) GetExtClient ¶ added in v1.21.0
func (c *Clients) GetExtClient() (*extclientset.Clientset, error)
GetExtClient gets an instance of a kubernetes client that includes all the api extensions.
func (*Clients) GetKubeClient ¶ added in v1.21.0
func (c *Clients) GetKubeClient() (*kubernetes.Clientset, error)
GetKubeClient returns a Kubernetes rest client
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 // FeatureGates may be overridden for a framework FeatureGates []string }
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 // 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 *Clients // 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 calls NewFramework and handles errors by calling Fail. Config is optional, but if passed there can only be one. To understand the order in which things are run, read http://onsi.github.io/ginkgo/#understanding-ginkgos-lifecycle flag parsing happens AFTER ginkgo has constructed the entire testing tree. So anything that uses information from flags cannot work when called during test tree construction.
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) CreateBoundPVCFromDefinition ¶ added in v1.21.0
func (f *Framework) CreateBoundPVCFromDefinition(def *k8sv1.PersistentVolumeClaim) (*k8sv1.PersistentVolumeClaim, error)
CreateBoundPVCFromDefinition is a wrapper around utils.CreatePVCFromDefinition that also force binds pvc on on WaitForFirstConsumer storage class by executing f.ForceBindIfWaitForFirstConsumer(pvc)
func (*Framework) CreateExecutorPodWithPVC ¶
func (f *Framework) CreateExecutorPodWithPVC(podName, namespace string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error)
CreateExecutorPodWithPVC creates a Pod with the passed in PVC mounted under /pvc. You can then use the executor utilities to run commands against the PVC through this Pod.
func (*Framework) CreateExecutorPodWithPVCSpecificNode ¶ added in v1.10.7
func (f *Framework) CreateExecutorPodWithPVCSpecificNode(podName, namespace string, pvc *k8sv1.PersistentVolumeClaim, node string) (*k8sv1.Pod, error)
CreateExecutorPodWithPVCSpecificNode creates a Pod on a specific node with the passed in PVC mounted under /pvc. You can then use the executor utilities to run commands against the PVC through this Pod.
func (*Framework) CreateNamespace ¶
CreateNamespace instantiates a new namespace object with a unique name and the passed-in label(s).
func (*Framework) CreateNoopPodWithPVC ¶ added in v1.27.0
func (f *Framework) CreateNoopPodWithPVC(podName, namespace string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error)
CreateNoopPodWithPVC creates a short living pod, that might be used to force bind a pvc
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) CreateQuotaInNs ¶ added in v1.14.0
CreateQuotaInNs creates a quota and sets it on the current test namespace.
func (*Framework) CreateQuotaInSpecifiedNs ¶ added in v1.24.0
func (f *Framework) CreateQuotaInSpecifiedNs(ns string, requestCPU, requestMemory, limitsCPU, limitsMemory int64) error
CreateQuotaInSpecifiedNs creates a quota and sets it on the specified test namespace.
func (*Framework) CreateVerifierPodWithPVC ¶ added in v1.27.0
func (f *Framework) CreateVerifierPodWithPVC(namespace string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error)
CreateVerifierPodWithPVC creates a Pod called verifier, with the passed in PVC mounted under /pvc. You can then use the executor utilities to run commands against the PVC through this Pod.
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, 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 ¶
func (f *Framework) ExecCommandInPod(podName, namespace string, cmd ...string) (string, string, error)
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 ¶
func (f *Framework) ExecShellInContainer(namespace, podName, containerName string, cmd string) (string, string, error)
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(namespace, 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) FindPodBySuffix ¶ added in v1.14.0
FindPodBySuffix is a wrapper around utils.FindPodByPostFix
func (*Framework) ForceBindIfWaitForFirstConsumer ¶ added in v1.21.0
func (f *Framework) ForceBindIfWaitForFirstConsumer(targetPvc *k8sv1.PersistentVolumeClaim)
ForceBindIfWaitForFirstConsumer creates a Pod with the passed in PVC mounted under /pvc, which forces the PVC to be scheduled and bound.
func (*Framework) ForceBindPvcIfDvIsWaitForFirstConsumer ¶ added in v1.21.0
func (f *Framework) ForceBindPvcIfDvIsWaitForFirstConsumer(dv *cdiv1.DataVolume)
ForceBindPvcIfDvIsWaitForFirstConsumer creates a Pod with the PVC for passed in DV mounted under /pvc, which forces the PVC to be scheduled and bound.
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) GetDiskGroup ¶ added in v1.15.0
func (f *Framework) GetDiskGroup(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, deletePod bool) (string, error)
GetDiskGroup returns the group of a disk image.
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) GetRESTConfigForServiceAccount ¶ added in v1.26.0
GetRESTConfigForServiceAccount returns a RESTConfig for SA
func (*Framework) IsBindingModeWaitForFirstConsumer ¶ added in v1.21.0
IsBindingModeWaitForFirstConsumer checks if the storage class with specified name has the VolumeBindingMode set to WaitForFirstConsumer
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) NewPodWithPVC ¶ added in v1.27.0
NewPodWithPVC creates a new pod that mounts the given PVC
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) UpdateCdiConfigResourceLimits ¶ added in v1.14.0
func (f *Framework) UpdateCdiConfigResourceLimits(resourceCPU, resourceMemory, limitsCPU, limitsMemory int64) error
UpdateCdiConfigResourceLimits sets the limits in the CDIConfig object
func (*Framework) UpdateQuotaInNs ¶ added in v1.14.0
UpdateQuotaInNs updates an existing quota in the current test namespace.
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) VerifyPermissions ¶ added in v1.19.0
func (f *Framework) VerifyPermissions(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
VerifyPermissions returns the group of a disk image.
func (*Framework) VerifySparse ¶ added in v1.13.2
func (f *Framework) VerifySparse(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim) (bool, error)
VerifySparse checks a disk image 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) 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) WaitPVCDeletedByUID ¶ added in v1.20.0
func (f *Framework) WaitPVCDeletedByUID(pvcSpec *k8sv1.PersistentVolumeClaim, timeout time.Duration) (bool, error)
WaitPVCDeletedByUID is a wrapper around utils.WaitPVCDeletedByUID
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
type KubernetesReporter ¶ added in v1.12.0
type KubernetesReporter struct { FailureCount int // contains filtered or unexported fields }
KubernetesReporter is the struct that holds the report info.
func NewKubernetesReporter ¶ added in v1.12.0
func NewKubernetesReporter() *KubernetesReporter
NewKubernetesReporter creates a new instance of the reporter.
func (*KubernetesReporter) Cleanup ¶ added in v1.12.0
func (r *KubernetesReporter) Cleanup()
Cleanup cleans up the current content of the artifactsDir
func (*KubernetesReporter) Dump ¶ added in v1.12.0
func (r *KubernetesReporter) Dump(kubeCli *kubernetes.Clientset, cdiClient *cdiClientset.Clientset, since time.Duration)
Dump dumps the current state of the cluster. The relevant logs are collected starting from the since parameter.