framework

package
v0.0.0-...-3509752 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabelsToNamespace

func AddLabelsToNamespace(kubeClient kubernetes.Interface, name string, additionalLabels map[string]string) error

func CreateCRD

func CreateCRD(kubeClient clientset.Interface, namespace string, crd *apiextensionsv1.CustomResourceDefinition) error

func CreateClusterRole

func CreateClusterRole(kubeClient kubernetes.Interface, relativePath string) error

func CreateClusterRoleBinding

func CreateClusterRoleBinding(kubeClient kubernetes.Interface, ns string, relativePath string) (finalizerFn, error)

func CreateDeployment

func CreateDeployment(kubeClient kubernetes.Interface, namespace string, d *appsv1.Deployment) error

func CreateNamespace

func CreateNamespace(kubeClient kubernetes.Interface, name string) (*v1.Namespace, error)

func CreateRoleBinding

func CreateRoleBinding(kubeClient kubernetes.Interface, ns string, relativePath string) (finalizerFn, error)

func CreateServiceAccount

func CreateServiceAccount(kubeClient kubernetes.Interface, namespace string, relativPath string) (finalizerFn, error)

func DeleteClusterRole

func DeleteClusterRole(kubeClient kubernetes.Interface, relativePath string) error

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(kubeClient kubernetes.Interface, relativePath string) error

func DeleteDeployment

func DeleteDeployment(kubeClient kubernetes.Interface, namespace, name string) error

func DeleteNamespace

func DeleteNamespace(kubeClient kubernetes.Interface, name string) error

func DeleteRoleBinding

func DeleteRoleBinding(kubeClient kubernetes.Interface, ns string, relativePath string) error

func DeleteServiceAccount

func DeleteServiceAccount(kubeClient kubernetes.Interface, namespace string, relativPath string) error

func MakeBasicProxier

func MakeBasicProxier(ns, name string, versions []string, weights []int32) *maegusv1.Proxier

MakeBasicProxier returns a proxier with given versions and weights.

func MakeCRD

func MakeCRD(pathToYaml string) (*apiextensionsv1.CustomResourceDefinition, error)

func MakeDeployment

func MakeDeployment(pathToYaml string) (*appsv1.Deployment, error)

func MakePod

func MakePod(pathToYaml string) (*v1.Pod, error)

func PathToOSFile

func PathToOSFile(relativPath string) (*os.File, error)

PathToOSFile opens a file and return the os.File pointer.

func PodRunningAndReady

func PodRunningAndReady(pod v1.Pod) (bool, error)

PodRunningAndReady returns whether a pod is running and each container has passed it's ready state.

func WaitForCRDReady

func WaitForCRDReady(listFunc func(opts metav1.ListOptions) (runtime.Object, error)) error

WaitForCRDReady waits for a custom resource definition to be available for use.

func WaitForPodsReady

func WaitForPodsReady(kubeClient kubernetes.Interface, namespace string, timeout time.Duration, expectedReplicas int, opts metav1.ListOptions) error

WaitForPodsReady waits for a selection of Pods to be running and each container to pass its readiness check.

func WaitUntilDeploymentGone

func WaitUntilDeploymentGone(kubeClient kubernetes.Interface, namespace, name string, timeout time.Duration) error

Types

type Framework

type Framework struct {
	KubeClient            kubernetes.Interface
	MaegusClientV1        maegusclient.MaegusV1beta1Interface
	ApiextensionsClientV1 clientset.Interface
	HTTPClient            *http.Client
	MasterHost            string
	DefaultTimeout        time.Duration
}

func New

func New(kubeconfig, opImage string) (*Framework, error)

New setups a test framework and returns it.

func (*Framework) CreatePod

func (f *Framework) CreatePod(namespace string, pod *v1.Pod) error

func (*Framework) CreatePodAndWaitUntilReady

func (f *Framework) CreatePodAndWaitUntilReady(namespace string, pod *v1.Pod) error

func (*Framework) CreateProxier

func (f *Framework) CreateProxier(ns string, p *maegusv1.Proxier) (*maegusv1.Proxier, error)

CreateProxier creates a proxier.

func (*Framework) CreateProxierAndWaitUntilReady

func (f *Framework) CreateProxierAndWaitUntilReady(ns string, p *maegusv1.Proxier) (*maegusv1.Proxier, error)

CreateProxierAndWaitUntilReady creates a proxier instance and waits until ready.

func (*Framework) CreateProxierOperator

func (f *Framework) CreateProxierOperator(namespace string, operatorImage string, namespacesToWatch []string) error

CreateProxierOperator create service account, cluster role, cluster role binding and make deployment for proxier resources.

func (*Framework) GetPodRestartCount

func (f *Framework) GetPodRestartCount(ns, podName string) (map[string]int32, error)

GetPodRestartCount returns a map of container names and their restart counts for a given pod.

func (*Framework) NewTestCtx

func (f *Framework) NewTestCtx(t *testing.T) TestCtx

func (*Framework) UpdateProxier

func (f *Framework) UpdateProxier(ns string, p *maegusv1.Proxier) (*maegusv1.Proxier, error)

UpdateProxier updates a proxier instance.

func (*Framework) UpdateProxierAndWaitUntilReady

func (f *Framework) UpdateProxierAndWaitUntilReady(ns string, p *maegusv1.Proxier) (*maegusv1.Proxier, error)

UpdateProxierAndWaitUntilReady updates a proxier instance and waits until ready.

func (*Framework) WaitForDeployment

func (f *Framework) WaitForDeployment(namespace, name string, timeout time.Duration) error

WaitForDeployment returns when deployment is created.

func (*Framework) WaitForPodReady

func (f *Framework) WaitForPodReady(pod *v1.Pod, timeout time.Duration) error

WaitForPodReady returns when pod shifted to running phase or timeout.

func (*Framework) WaitForProxierReady

func (f *Framework) WaitForProxierReady(p *maegusv1.Proxier, timeout time.Duration) error

WaitForProxierReady returns when proxier shifted to running phase or timeout.

func (*Framework) WaitForServiceReady

func (f *Framework) WaitForServiceReady(namespace, name string, timeout time.Duration) error

WaitForServiceReady returns when service is ready.

func (*Framework) WaitUntilServiceGone

func (f *Framework) WaitUntilServiceGone(namespace, name string, timeout time.Duration) error

WaitUntilServiceGone returns when service not found.

type TestCtx

type TestCtx struct {
	ID string
	// contains filtered or unexported fields
}

func (*TestCtx) AddFinalizerFn

func (ctx *TestCtx) AddFinalizerFn(fn finalizerFn)

func (*TestCtx) Cleanup

func (ctx *TestCtx) Cleanup(t *testing.T)

func (*TestCtx) CreateNamespace

func (ctx *TestCtx) CreateNamespace(t *testing.T, kubeClient kubernetes.Interface) string

func (*TestCtx) GetObjID

func (ctx *TestCtx) GetObjID() string

GetObjID returns an ascending ID based on the length of cleanUpFns. It is based on the premise that every new object also appends a new finalizerFn on cleanUpFns. This can e.g. be used to create multiple namespaces in the same test context.

func (*TestCtx) SetupProxierRBAC

func (ctx *TestCtx) SetupProxierRBAC(t *testing.T, ns string, kubeClient kubernetes.Interface)

Jump to

Keyboard shortcuts

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