framework

package
v0.0.0-...-37b7bf9 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabelsToNamespace

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

func CreateDeployment

func CreateDeployment(client kubernetes.Interface, namespace string, deployment *appv1.Deployment) error

func CreateNamespace

func CreateNamespace(client kubernetes.Interface, name string) (*corev1.Namespace, error)

func CreateOrUpdateClusterRole

func CreateOrUpdateClusterRole(client kubernetes.Interface, relativeFilePath string) error

func DeleteClusterRole

func DeleteClusterRole(client kubernetes.Interface, relativeFilePath string) error

func DeleteClusterRoleBinding

func DeleteClusterRoleBinding(client kubernetes.Interface, relativeFilePath string) error

func DeleteDeployment

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

func DeleteNamespace

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

func DeleteRoleBinding

func DeleteRoleBinding(client kubernetes.Interface, namespace string, relativeFilePath string) error

func DeleteServiceAccount

func DeleteServiceAccount(client kubernetes.Interface, namespace, relativeFilePath string) error

func GetFileDescriptor

func GetFileDescriptor(relativeFilePath string) (*os.File, error)

GetFileDescriptor returns the file descriptor for the given relative file path.

func MakeBasicBalancer

func MakeBasicBalancer(namespace, name string, versions []string, weights []int32) *balancerv1alpha1.Balancer

func ParseCRDYaml

func ParseCRDYaml(relativeFilePath string) (*apiextensionsv1beta1.CustomResourceDefinition, error)

func ParseClusterRoleBindingYaml

func ParseClusterRoleBindingYaml(relativeFilePath string) (*rbacv1.ClusterRoleBinding, error)

ParseClusterRoleBindingYaml creates a ClusterRoleBinding resource with given yaml file path.

func ParseClusterRoleYaml

func ParseClusterRoleYaml(relativeFilePath string) (*rbacv1.ClusterRole, error)

ParseClusterRoleYaml creates a ClusterRole resource with given yaml file path.

func ParseDeploymentYaml

func ParseDeploymentYaml(relativeFilePath string) (*appv1.Deployment, error)

func ParsePodYaml

func ParsePodYaml(relativeFilePath string) (*corev1.Pod, error)

func ParseRoleBindingYaml

func ParseRoleBindingYaml(relativeFilePath string) (*rbacv1.RoleBinding, error)

func ParseServiceAccountYaml

func ParseServiceAccountYaml(relativeFilePath string) (*corev1.ServiceAccount, error)

func PodRunningAndReady

func PodRunningAndReady(pod *corev1.Pod) (bool, error)

PodRunningAndReady returns true if pod is ready and its current status is running.

func WaitForCRDReady

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

func WaitForPodReady

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

WaitForPodReady checks whether expectedReplicas pods are running and ready.

func WaitUntilDeploymentGone

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

WaitUntilDeploymentGone returns true only if the deployment is deleted.

Types

type FinalizeFunc

type FinalizeFunc func() error

func CreateOrUpdateClusterRoleBinding

func CreateOrUpdateClusterRoleBinding(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)

func CreateRoleBinding

func CreateRoleBinding(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)

func CreateServiceAccount

func CreateServiceAccount(client kubernetes.Interface, namespace, relativeFilePath string) (FinalizeFunc, error)

type Framework

type Framework struct {
	// client for operate k8s core resources
	KubeClient kubernetes.Interface
	// client for operate hliangzhao.io resources
	ExposerClientV1alpha1 exposerv1alpha1.ExposerV1alpha1Interface
	// client for operate extension resources
	ApiextensionsClientV1 apiextensionsv1.Interface
	HttpClient            *http.Client
	MasterHost            string
	DefaultTimeout        time.Duration
}

Framework is a test framework

func NewFramework

func NewFramework(kubeconfig string) (*Framework, error)

func (*Framework) CreateBalancer

func (f *Framework) CreateBalancer(namespace string,
	balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)

func (*Framework) CreateBalancerAndWaitUntilReady

func (f *Framework) CreateBalancerAndWaitUntilReady(namespace string,
	balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)

func (*Framework) CreateBalancerOperator

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

func (*Framework) CreatePod

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

CreatePod creates pod in given namespace.

func (*Framework) CreatePodAndWaitUntilReady

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

func (*Framework) GetPodRestartCount

func (f *Framework) GetPodRestartCount(namespace, name string) (map[string]int32, error)

GetPodRestartCount gets a map recording each container's restart count for the given pod.

func (*Framework) NewTestContext

func (f *Framework) NewTestContext(t *testing.T) TestContext

func (*Framework) UpdateBalancer

func (f *Framework) UpdateBalancer(namespace string,
	balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)

func (*Framework) UpdateBalancerAndWaitUntilReady

func (f *Framework) UpdateBalancerAndWaitUntilReady(namespace string,
	balancer *balancerv1alpha1.Balancer) (*balancerv1alpha1.Balancer, error)

func (*Framework) WaitForBalancerReady

func (f *Framework) WaitForBalancerReady(balancer *balancerv1alpha1.Balancer, timeout time.Duration) error

func (*Framework) WaitForDeploymentCreated

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

WaitForDeploymentCreated returns true only if the deployment is created.

func (*Framework) WaitForPodReady

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

WaitForPodReady detects pod is ready or not within timeout.

func (*Framework) WaitForServiceCreated

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

WaitForServiceCreated returns true only if the service is created.

func (*Framework) WaitUntilServiceGone

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

WaitUntilServiceGone returns true only if the service is deleted.

type TestContext

type TestContext struct {
	Id string
	// contains filtered or unexported fields
}

func (*TestContext) AddFinalizerFunc

func (ctx *TestContext) AddFinalizerFunc(fn FinalizeFunc)

func (*TestContext) Cleanup

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

func (*TestContext) CreateNamespace

func (ctx *TestContext) CreateNamespace(t *testing.T, client kubernetes.Interface) string

func (*TestContext) GetObjId

func (ctx *TestContext) 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 (*TestContext) SetupBalancerRBAC

func (ctx *TestContext) SetupBalancerRBAC(t *testing.T, namespace string, kubeClient kubernetes.Interface)

Jump to

Keyboard shortcuts

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