utils

package
v0.0.0-...-3d9e2e8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package utils contains Kubernetes helpers to run tests against a running cluster

Index

Constants

View Source
const (
	// NamespaceCleanupTimeout failures caused by leaked resources from a previous test run.
	NamespaceCleanupTimeout = 5 * time.Minute
	// WaitForIngressAddressTimeout wait time for valid ingress status
	WaitForIngressAddressTimeout = 5 * time.Minute
	// IngressWaitInterval time to wait between checks for a condition
	IngressWaitInterval = 5 * time.Second
)
View Source
const (
	// IngressClassKey indicates the class of an Ingress to be used
	// when determining which controller should implement the Ingress
	IngressClassKey = "kubernetes.io/ingress.class"
)

Variables

View Source
var (
	// IngressClassValue sets the value of the class of Ingresses
	IngressClassValue = ""

	ManifestPath string
)
View Source
var KubeClient *kubernetes.Clientset

KubeClient Kubernetes API client

Functions

func CleanupNamespaces

func CleanupNamespaces(c kubernetes.Interface) error

CleanupNamespaces removes namespaces created by conformance tests

func CreateFromPath

func CreateFromPath(c clientset.Interface,
	manifest, ns string,
	ingAnnotations map[string]string,
	svcAnnotations map[string]string) (*networkingv1beta1.Ingress, error)

CreateFromPath creates the Ingress and associated service/rc. Required: ing.yaml, rc.yaml, svc.yaml must exist in manifestPath Optional: secret.yaml, ingAnnotations, svcAnnotations If ingAnnotations is specified it will overwrite any annotations in ing.yaml If svcAnnotations is specified it will overwrite any annotations in svc.yaml

func CreateIngress

func CreateIngress(c kubernetes.Interface, ingress *v1beta1.Ingress) (*v1beta1.Ingress, error)

CreateIngress creates an Ingress object and retunrs it, throws error if it already exists.

func CreateTestNamespace

func CreateTestNamespace(c kubernetes.Interface) (string, error)

CreateTestNamespace creates a new namespace using ingress-conformance- as prefix.

func DeleteKubeNamespace

func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error

DeleteKubeNamespace deletes a namespace and all the objects inside

func Exists

func Exists(path string) bool

Exists checks whether a file could be read. Unexpected errors are handled by calling the fail function, which then should abort the current test.

func IngressFromManifest

func IngressFromManifest(file, namespace string) (*networkingv1beta1.Ingress, error)

IngressFromManifest reads a .json/yaml file and returns the ingress in it.

func IsDir

func IsDir(path string) bool

func IsRetryableAPIError

func IsRetryableAPIError(err error) bool

IsRetryableAPIError checks if an API error allows retries or not

func LoadClientset

func LoadClientset() (*clientset.Clientset, error)

LoadClientset returns clientset for connecting to kubernetes clusters.

func Read

func Read(path string) ([]byte, error)

Read tries to retrieve the desired file content from one of the registered file sources.

func WaitForIngressAddress

func WaitForIngressAddress(c clientset.Interface, ns, ingName string, timeout time.Duration) (string, error)

WaitForIngressAddress waits for the Ingress to acquire an address.

func WaitForService

func WaitForService(c clientset.Interface, namespace, name string, exist bool, interval, timeout time.Duration) error

WaitForService waits until the service appears (exist == true), or disappears (exist == false)

func WaitForServiceEndpointsNum

func WaitForServiceEndpointsNum(c clientset.Interface, namespace, serviceName string,
	expectNum int, interval, timeout time.Duration) error

WaitForServiceEndpointsNum waits until the amount of endpoints that implement service to expectNum.

Types

This section is empty.

Jump to

Keyboard shortcuts

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