Documentation ¶
Overview ¶
Package utils contains Kubernetes helpers to run tests against a running cluster
Index ¶
- Constants
- Variables
- func CleanupNamespaces(c kubernetes.Interface) error
- func CreateFromPath(c clientset.Interface, manifest, ns string, ingAnnotations map[string]string, ...) (*networkingv1beta1.Ingress, error)
- func CreateIngress(c kubernetes.Interface, ingress *v1beta1.Ingress) (*v1beta1.Ingress, error)
- func CreateTestNamespace(c kubernetes.Interface) (string, error)
- func DeleteKubeNamespace(c kubernetes.Interface, namespace string) error
- func Exists(path string) bool
- func IngressFromManifest(file, namespace string) (*networkingv1beta1.Ingress, error)
- func IsDir(path string) bool
- func IsRetryableAPIError(err error) bool
- func LoadClientset() (*clientset.Clientset, error)
- func Read(path string) ([]byte, error)
- func WaitForIngressAddress(c clientset.Interface, ns, ingName string, timeout time.Duration) (string, error)
- func WaitForService(c clientset.Interface, namespace, name string, exist bool, ...) error
- func WaitForServiceEndpointsNum(c clientset.Interface, namespace, serviceName string, expectNum int, ...) error
Constants ¶
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 )
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 ¶
var ( // IngressClassValue sets the value of the class of Ingresses IngressClassValue = "" ManifestPath string )
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 ¶
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 ¶
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 IsRetryableAPIError ¶
IsRetryableAPIError checks if an API error allows retries or not
func LoadClientset ¶
LoadClientset returns clientset for connecting to kubernetes clusters.
func Read ¶
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.
Types ¶
This section is empty.