framework

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Copyright 2016 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.

Index

Constants

View Source
const (
	NsCreateTime  = 30 * time.Second
	NsDeleteTime  = 5 * time.Minute
	NsPrefixLabel = "cdi-e2e"
	CdiPodPrefix  = "cdi-deployment"
)

Variables

This section is empty.

Functions

func DeleteNS

func DeleteNS(c *kubernetes.Clientset, ns string) error

func GetKubeClientFromRESTConfig

func GetKubeClientFromRESTConfig(config *rest.Config) (*kubernetes.Clientset, error)

func VerifyPVCIsEmpty

func VerifyPVCIsEmpty(f *Framework, pvc *k8sv1.PersistentVolumeClaim) bool

Verify passed in PVC is empty, returns true if the PVC is empty, false if it is not.

Types

type Config

type Config struct {
	// 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
	// Whether to skip looking up the name of the cdi controller pod.
	SkipControllerPodLookup bool
}

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
	// prefix for generated namespace
	NsPrefix string
	//  k8s client
	K8sClient *kubernetes.Clientset
	// cdi client
	CdiClient *cdiClientset.Clientset
	// REST client config.
	RestConfig *rest.Config
	// generated/unique ns per test
	Namespace *v1.Namespace
	// generated/unique secondary ns for testing across namespaces (eg. clone tests)
	Namespace2 *v1.Namespace // note: not instantiated in NewFramework

	ControllerPod *v1.Pod

	// test run-time flags
	KubectlPath  string
	OcPath       string
	CdiInstallNs string
	KubeConfig   string
	Master       string
	GoCLIPath    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

func NewFramework(prefix string, config Config) (*Framework, error)

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

func NewFrameworkOrDie(prefix string, config ...Config) *Framework

NewFrameworkOrDie calls NewFramework and handles errors by calling Fail. Config is optional, but if passed there can only be one.

func (*Framework) AddNamespaceToDelete

func (f *Framework) AddNamespaceToDelete(ns *v1.Namespace)

func (*Framework) AfterEach

func (f *Framework) AfterEach()

func (*Framework) BeforeEach

func (f *Framework) BeforeEach()

func (*Framework) CreateAndPopulateSourcePVC

func (f *Framework) CreateAndPopulateSourcePVC(pvcName string, podName string, fillCommand string) *k8sv1.PersistentVolumeClaim

func (*Framework) CreateExecutorPodWithPVC

func (f *Framework) CreateExecutorPodWithPVC(podName string, pvc *k8sv1.PersistentVolumeClaim) (*k8sv1.Pod, error)

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(prefix string, labels map[string]string) (*v1.Namespace, error)

Instantiate 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)

func (*Framework) CreatePod

func (f *Framework) CreatePod(podDef *k8sv1.Pod) (*k8sv1.Pod, error)

func (*Framework) DeletePVC

func (f *Framework) DeletePVC(pvc *k8sv1.PersistentVolumeClaim) error

func (*Framework) DeletePod

func (f *Framework) DeletePod(pod *k8sv1.Pod) error

func (*Framework) ExecCommandInContainer

func (f *Framework) ExecCommandInContainer(namespace, podName, containerName string, cmd ...string) string

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

func (*Framework) ExecCommandInPodWithFullOutput

func (f *Framework) ExecCommandInPodWithFullOutput(namespace, podName string, cmd ...string) (string, string, error)

func (*Framework) ExecShellInContainer

func (f *Framework) ExecShellInContainer(podName, containerName string, cmd string) string

func (*Framework) ExecShellInPod

func (f *Framework) ExecShellInPod(podName, namespace string, cmd string) string

func (*Framework) ExecShellInPodWithFullOutput

func (f *Framework) ExecShellInPodWithFullOutput(podName string, cmd string) (string, string, error)

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)

func (*Framework) FindPodByPrefix

func (f *Framework) FindPodByPrefix(prefix string) (*k8sv1.Pod, error)

func (*Framework) GetCdiClient

func (f *Framework) GetCdiClient() (*cdiClientset.Clientset, error)

Gets an instance of a kubernetes client that includes all the CDI extensions.

func (*Framework) GetKubeClient

func (f *Framework) GetKubeClient() (*kubernetes.Clientset, error)

func (*Framework) LoadConfig

func (f *Framework) LoadConfig() (*rest.Config, error)

func (*Framework) VerifyTargetPVCContent

func (f *Framework) VerifyTargetPVCContent(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, expectedData string) bool

func (*Framework) VerifyTargetPVCContentMD5

func (f *Framework) VerifyTargetPVCContentMD5(namespace *k8sv1.Namespace, pvc *k8sv1.PersistentVolumeClaim, fileName string, expectedHash string) bool

func (*Framework) WaitForPersistentVolumeClaimPhase

func (f *Framework) WaitForPersistentVolumeClaimPhase(phase k8sv1.PersistentVolumeClaimPhase, pvcName string) error

func (*Framework) WaitTimeoutForPodReady

func (f *Framework) WaitTimeoutForPodReady(podName string, timeout time.Duration) error

func (*Framework) WaitTimeoutForPodStatus

func (f *Framework) WaitTimeoutForPodStatus(podName string, status k8sv1.PodPhase, timeout time.Duration) error

Jump to

Keyboard shortcuts

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