Documentation ¶
Index ¶
- Constants
- Variables
- func CreateIngressMASecret(client kubernetes.Interface, host string, secretName, namespace string) (*tls.Config, error)
- func CreateIngressTLSSecret(client kubernetes.Interface, hosts []string, secretName, namespace string) (*tls.Config, error)
- func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error)
- func DescribeAnnotation(text string, body func()) bool
- func DescribeSetting(text string, body func()) bool
- func Failf(format string, args ...interface{})
- func IngressNginxDescribe(text string, body func()) bool
- func Logf(format string, args ...interface{})
- func Logs(client kubernetes.Interface, namespace, podName string) (string, error)
- func MemoryLeakIt(text string, body interface{}, timeout ...float64) bool
- func NewInt32(val int32) *int32
- func NewInt64(val int64) *int64
- func NewSingleCatchAllIngress(name, ns, service string, port int, annotations map[string]string) *networking.Ingress
- func NewSingleIngress(name, path, host, ns, service string, port int, annotations map[string]string) *networking.Ingress
- func NewSingleIngressWithBackendAndRules(name, path, host, ns, defaultService string, defaultPort int, service string, ...) *networking.Ingress
- func NewSingleIngressWithMultiplePaths(name string, paths []string, host, ns, service string, port int, ...) *networking.Ingress
- func NewSingleIngressWithTLS(name, path, host string, tlsHosts []string, ns, service string, port int, ...) *networking.Ingress
- func RegisterParseFlags()
- func RestclientConfig(config, context string) (*api.Config, error)
- func Sleep(duration ...time.Duration)
- func UpdateDeployment(kubeClientSet kubernetes.Interface, namespace string, name string, ...) error
- func UpdateIngress(kubeClientSet kubernetes.Interface, namespace string, name string, ...) error
- func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration, name, ns string, ...) error
- func WaitForFileInFS(file string) error
- func WaitForIngressInNamespace(c kubernetes.Interface, namespace, name string) error
- func WaitForKubeNamespaceNotExist(c kubernetes.Interface, namespace string) error
- func WaitForNoIngressInNamespace(c kubernetes.Interface, namespace, name string) error
- func WaitForNoPodsInNamespace(c kubernetes.Interface, namespace string) error
- func WaitForPodRunningInNamespace(c kubernetes.Interface, pod *corev1.Pod) error
- func WaitForSecretInNamespace(c kubernetes.Interface, namespace, name string) error
- func WaitForTLS(url string, tlsConfig *tls.Config)
- type Framework
- func (f *Framework) AfterEach()
- func (f *Framework) BeforeEach()
- func (f *Framework) CreateConfigMap(name string, data map[string]string)
- func (f *Framework) DeleteDeployment(name string) error
- func (f *Framework) DeleteNGINXPod(grace int64)
- func (f *Framework) EnsureConfigMap(configMap *api.ConfigMap) (*api.ConfigMap, error)
- func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) *appsv1.Deployment
- func (f *Framework) EnsureIngress(ingress *networking.Ingress) *networking.Ingress
- func (f *Framework) EnsureSecret(secret *api.Secret) *api.Secret
- func (f *Framework) EnsureService(service *core.Service) *core.Service
- func (f *Framework) ExecCommand(pod *corev1.Pod, command string) (string, error)
- func (f *Framework) ExecIngressPod(command string) (string, error)
- func (f *Framework) GetIngress(namespace string, name string) *networking.Ingress
- func (f *Framework) GetIngressNGINXPod() *corev1.Pod
- func (f *Framework) GetLbAlgorithm(serviceName string, servicePort int) (string, error)
- func (f *Framework) GetMetric(metricName, ip string) (*dto.MetricFamily, error)
- func (f *Framework) GetNginxIP() string
- func (f *Framework) GetNginxPodIP() string
- func (f *Framework) GetURL(scheme RequestScheme) string
- func (f *Framework) HTTPTestClient() *httpexpect.Expect
- func (f *Framework) HTTPTestClientWithTLSConfig(config *tls.Config) *httpexpect.Expect
- func (f *Framework) KubectlProxy(port int) (int, *exec.Cmd, error)
- func (f *Framework) NamespaceContent() (string, error)
- func (f *Framework) NewDeployment(name, image string, port int32, replicas int32)
- func (f *Framework) NewEchoDeployment()
- func (f *Framework) NewEchoDeploymentWithNameAndReplicas(name string, replicas int)
- func (f *Framework) NewEchoDeploymentWithReplicas(replicas int)
- func (f *Framework) NewFastCGIHelloServerDeployment()
- func (f *Framework) NewGRPCBinDeployment()
- func (f *Framework) NewGRPCFortuneTellerDeployment()
- func (f *Framework) NewHttpbinDeployment()
- func (f *Framework) NewInfluxDBDeployment()
- func (f *Framework) NewNewFastCGIHelloServerDeploymentWithReplicas(replicas int32)
- func (f *Framework) NewNewGRPCFortuneTellerDeploymentWithReplicas(replicas int32)
- func (f *Framework) NewSlowEchoDeployment()
- func (f *Framework) NginxLogs() (string, error)
- func (f *Framework) ScaleDeploymentToZero(name string)
- func (f *Framework) SetNginxConfigMapData(cmData map[string]string)
- func (f *Framework) UpdateIngress(ingress *networking.Ingress) *networking.Ingress
- func (f *Framework) UpdateIngressControllerDeployment(fn func(deployment *appsv1.Deployment) error) error
- func (f *Framework) UpdateNginxConfigMapData(key string, value string)
- func (f *Framework) WaitForNginxConfiguration(matcher func(cfg string) bool)
- func (f *Framework) WaitForNginxCustomConfiguration(from string, to string, matcher func(cfg string) bool)
- func (f *Framework) WaitForNginxListening(port int)
- func (f *Framework) WaitForNginxServer(name string, matcher func(cfg string) bool)
- type RequestScheme
- type TestContextType
Constants ¶
const ( // Poll how often to poll for conditions Poll = 2 * time.Second // DefaultTimeout time to wait for operations to complete DefaultTimeout = 5 * time.Minute )
const EchoService = "echo"
EchoService name of the deployment for the echo app
const HTTPBinService = "httpbin"
HTTPBinService name of the deployment for the httpbin app
const SlowEchoService = "slow-echo"
SlowEchoService name of the deployment for the echo app
Variables ¶
var (
// KubectlPath defines the full path of the kubectl binary
KubectlPath = "/usr/local/bin/kubectl"
)
var RunID = uuid.NewUUID()
RunID unique identifier of the e2e run
Functions ¶
func CreateIngressMASecret ¶
func CreateIngressMASecret(client kubernetes.Interface, host string, secretName, namespace string) (*tls.Config, error)
CreateIngressMASecret creates or updates a Secret containing a Mutual Auth certificate-chain for the given Ingress and returns a TLS configuration suitable for HTTP clients to use against that particular Ingress.
func CreateIngressTLSSecret ¶
func CreateIngressTLSSecret(client kubernetes.Interface, hosts []string, secretName, namespace string) (*tls.Config, error)
CreateIngressTLSSecret creates or updates a Secret containing a TLS certificate for the given Ingress and returns a TLS configuration suitable for HTTP clients to use against that particular Ingress.
func CreateKubeNamespace ¶
func CreateKubeNamespace(baseName string, c kubernetes.Interface) (string, error)
CreateKubeNamespace creates a new namespace in the cluster
func DescribeAnnotation ¶
DescribeAnnotation wrapper function for ginkgo describe. Adds namespacing.
func DescribeSetting ¶
DescribeSetting wrapper function for ginkgo describe. Adds namespacing.
func Failf ¶
func Failf(format string, args ...interface{})
Failf logs to the INFO logs and fails the test.
func IngressNginxDescribe ¶
IngressNginxDescribe wrapper function for ginkgo describe. Adds namespacing.
func Logs ¶
func Logs(client kubernetes.Interface, namespace, podName string) (string, error)
Logs returns the log entries of a given Pod.
func MemoryLeakIt ¶
MemoryLeakIt is wrapper function for ginkgo It. Adds "[MemoryLeak]" tag and makes static analysis easier.
func NewSingleCatchAllIngress ¶
func NewSingleCatchAllIngress(name, ns, service string, port int, annotations map[string]string) *networking.Ingress
NewSingleCatchAllIngress creates a simple ingress with a catch-all backend
func NewSingleIngress ¶
func NewSingleIngress(name, path, host, ns, service string, port int, annotations map[string]string) *networking.Ingress
NewSingleIngress creates a simple ingress rule
func NewSingleIngressWithBackendAndRules ¶
func NewSingleIngressWithBackendAndRules(name, path, host, ns, defaultService string, defaultPort int, service string, port int, annotations map[string]string) *networking.Ingress
NewSingleIngressWithBackendAndRules creates an ingress with both a default backend and a rule
func NewSingleIngressWithMultiplePaths ¶
func NewSingleIngressWithMultiplePaths(name string, paths []string, host, ns, service string, port int, annotations map[string]string) *networking.Ingress
NewSingleIngressWithMultiplePaths creates a simple ingress rule with multiple paths
func NewSingleIngressWithTLS ¶
func NewSingleIngressWithTLS(name, path, host string, tlsHosts []string, ns, service string, port int, annotations map[string]string) *networking.Ingress
NewSingleIngressWithTLS creates a simple ingress rule with TLS spec included
func RegisterParseFlags ¶
func RegisterParseFlags()
RegisterParseFlags registers and parses flags for the test binary.
func RestclientConfig ¶
RestclientConfig deserializes the contents of a kubeconfig file into a Config object.
func Sleep ¶
Sleep pauses the current goroutine for at least the duration d. If no duration is defined, it uses a default
func UpdateDeployment ¶
func UpdateDeployment(kubeClientSet kubernetes.Interface, namespace string, name string, replicas int, updateFunc func(d *appsv1.Deployment) error) error
UpdateDeployment runs the given updateFunc on the deployment and waits for it to be updated
func UpdateIngress ¶
func UpdateIngress(kubeClientSet kubernetes.Interface, namespace string, name string, updateFunc func(d *networking.Ingress) error) error
UpdateIngress runs the given updateFunc on the ingress
func WaitForEndpoints ¶
func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration, name, ns string, expectedEndpoints int) error
WaitForEndpoints waits for a given amount of time until the number of endpoints = expectedEndpoints.
func WaitForFileInFS ¶
WaitForFileInFS waits a default amount of time for the specified file is present in the filesystem
func WaitForIngressInNamespace ¶
func WaitForIngressInNamespace(c kubernetes.Interface, namespace, name string) error
WaitForIngressInNamespace waits until a particular ingress object exists namespace
func WaitForKubeNamespaceNotExist ¶
func WaitForKubeNamespaceNotExist(c kubernetes.Interface, namespace string) error
WaitForKubeNamespaceNotExist waits until a namespaces is not present in the cluster
func WaitForNoIngressInNamespace ¶
func WaitForNoIngressInNamespace(c kubernetes.Interface, namespace, name string) error
WaitForNoIngressInNamespace waits until there is no ingress object in a particular namespace
func WaitForNoPodsInNamespace ¶
func WaitForNoPodsInNamespace(c kubernetes.Interface, namespace string) error
WaitForNoPodsInNamespace waits until there are no pods running in a namespace
func WaitForPodRunningInNamespace ¶
func WaitForPodRunningInNamespace(c kubernetes.Interface, pod *corev1.Pod) error
WaitForPodRunningInNamespace waits a default amount of time (PodStartTimeout) for the specified pod to become running. Returns an error if timeout occurs first, or pod goes in to failed state.
func WaitForSecretInNamespace ¶
func WaitForSecretInNamespace(c kubernetes.Interface, namespace, name string) error
WaitForSecretInNamespace waits a default amount of time for the specified secret is present in a particular namespace
func WaitForTLS ¶
WaitForTLS waits until the TLS handshake with a given server completes successfully.
Types ¶
type Framework ¶
type Framework struct { BaseName string IsIngressV1Ready bool // A Kubernetes and Service Catalog client KubeClientSet kubernetes.Interface KubeConfig *restclient.Config APIExtensionsClientSet apiextcs.Interface Namespace string // contains filtered or unexported fields }
Framework supports common operations used by e2e tests; it will keep a client & a namespace for you.
func NewDefaultFramework ¶
NewDefaultFramework makes a new framework and sets up a BeforeEach/AfterEach for you (you can write additional before/after each functions).
func (*Framework) AfterEach ¶
func (f *Framework) AfterEach()
AfterEach deletes the namespace, after reading its events.
func (*Framework) BeforeEach ¶
func (f *Framework) BeforeEach()
BeforeEach gets a client and makes a namespace.
func (*Framework) CreateConfigMap ¶
CreateConfigMap creates a new configmap in the current namespace
func (*Framework) DeleteDeployment ¶
DeleteDeployment deletes a deployment with a particular name and waits for the pods to be deleted
func (*Framework) DeleteNGINXPod ¶
DeleteNGINXPod deletes the currently running pod. It waits for the replacement pod to be up. Grace period to wait for pod shutdown is in seconds.
func (*Framework) EnsureConfigMap ¶
EnsureConfigMap creates a ConfigMap object or returns it if it already exists.
func (*Framework) EnsureDeployment ¶
func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) *appsv1.Deployment
EnsureDeployment creates a Deployment object and retunrs it, throws error if it already exists.
func (*Framework) EnsureIngress ¶
func (f *Framework) EnsureIngress(ingress *networking.Ingress) *networking.Ingress
EnsureIngress creates an Ingress object and retunrs it, throws error if it already exists.
func (*Framework) EnsureSecret ¶
EnsureSecret creates a Secret object or returns it if it already exists.
func (*Framework) EnsureService ¶
EnsureService creates a Service object and retunrs it, throws error if it already exists.
func (*Framework) ExecCommand ¶
ExecCommand executes a command inside a the first container in a running pod
func (*Framework) ExecIngressPod ¶
ExecIngressPod executes a command inside the first container in ingress controller running pod
func (*Framework) GetIngress ¶
func (f *Framework) GetIngress(namespace string, name string) *networking.Ingress
GetIngress gets an Ingress object from the given namespace, name and retunrs it, throws error if it does not exists.
func (*Framework) GetIngressNGINXPod ¶
GetIngressNGINXPod returns the ingress controller running pod
func (*Framework) GetLbAlgorithm ¶
GetLbAlgorithm returns algorithm identifier for the given backend
func (*Framework) GetMetric ¶
func (f *Framework) GetMetric(metricName, ip string) (*dto.MetricFamily, error)
GetMetric returns the current prometheus metric exposed by NGINX
func (*Framework) GetNginxIP ¶
GetNginxIP returns the number of TCP port where NGINX is running
func (*Framework) GetNginxPodIP ¶
GetNginxPodIP returns the IP addresses of the running pods
func (*Framework) GetURL ¶
func (f *Framework) GetURL(scheme RequestScheme) string
GetURL returns the URL should be used to make a request to NGINX
func (*Framework) HTTPTestClient ¶
func (f *Framework) HTTPTestClient() *httpexpect.Expect
HTTPTestClient returns a new httpexpect client for end-to-end HTTP testing.
func (*Framework) HTTPTestClientWithTLSConfig ¶
HTTPTestClientWithTLSConfig returns a new httpexpect client for end-to-end HTTP testing with a custom TLS configuration.
func (*Framework) KubectlProxy ¶
KubectlProxy creates a proxy to kubernetes apiserver
func (*Framework) NamespaceContent ¶
NamespaceContent executes a kubectl command that returns information about pods, services, endpoint and deployments inside the current namespace
func (*Framework) NewDeployment ¶
NewDeployment creates a new deployment in a particular namespace.
func (*Framework) NewEchoDeployment ¶
func (f *Framework) NewEchoDeployment()
NewEchoDeployment creates a new single replica deployment of the echoserver image in a particular namespace
func (*Framework) NewEchoDeploymentWithNameAndReplicas ¶
NewEchoDeploymentWithNameAndReplicas creates a new deployment of the echoserver image in a particular namespace. Number of replicas is configurable and name is configurable
func (*Framework) NewEchoDeploymentWithReplicas ¶
NewEchoDeploymentWithReplicas creates a new deployment of the echoserver image in a particular namespace. Number of replicas is configurable
func (*Framework) NewFastCGIHelloServerDeployment ¶
func (f *Framework) NewFastCGIHelloServerDeployment()
NewFastCGIHelloServerDeployment creates a new single replica deployment of the fortune teller image in a particular namespace
func (*Framework) NewGRPCBinDeployment ¶
func (f *Framework) NewGRPCBinDeployment()
NewGRPCBinDeployment creates a new deployment of the moul/grpcbin image for GRPC tests
func (*Framework) NewGRPCFortuneTellerDeployment ¶
func (f *Framework) NewGRPCFortuneTellerDeployment()
NewGRPCFortuneTellerDeployment creates a new single replica deployment of the fortune teller image in a particular namespace
func (*Framework) NewHttpbinDeployment ¶
func (f *Framework) NewHttpbinDeployment()
NewHttpbinDeployment creates a new single replica deployment of the httpbin image in a particular namespace.
func (*Framework) NewInfluxDBDeployment ¶
func (f *Framework) NewInfluxDBDeployment()
NewInfluxDBDeployment creates an InfluxDB server configured to reply on 8086/tcp and 8089/udp
func (*Framework) NewNewFastCGIHelloServerDeploymentWithReplicas ¶
NewNewFastCGIHelloServerDeploymentWithReplicas creates a new deployment of the fortune teller image in a particular namespace. Number of replicas is configurable
func (*Framework) NewNewGRPCFortuneTellerDeploymentWithReplicas ¶
NewNewGRPCFortuneTellerDeploymentWithReplicas creates a new deployment of the fortune teller image in a particular namespace. Number of replicas is configurable
func (*Framework) NewSlowEchoDeployment ¶
func (f *Framework) NewSlowEchoDeployment()
NewSlowEchoDeployment creates a new deployment of the slow echo server image in a particular namespace.
func (*Framework) NginxLogs ¶
NginxLogs returns the logs of the nginx ingress controller pod running
func (*Framework) ScaleDeploymentToZero ¶
ScaleDeploymentToZero scales a deployment with a particular name and waits for the pods to be deleted
func (*Framework) SetNginxConfigMapData ¶
SetNginxConfigMapData sets ingress-nginx's nginx-ingress-controller configMap data
func (*Framework) UpdateIngress ¶
func (f *Framework) UpdateIngress(ingress *networking.Ingress) *networking.Ingress
UpdateIngress updates an Ingress object and returns the updated object.
func (*Framework) UpdateIngressControllerDeployment ¶
func (f *Framework) UpdateIngressControllerDeployment(fn func(deployment *appsv1.Deployment) error) error
UpdateIngressControllerDeployment updates the ingress-nginx deployment
func (*Framework) UpdateNginxConfigMapData ¶
UpdateNginxConfigMapData updates single field in ingress-nginx's nginx-ingress-controller map data
func (*Framework) WaitForNginxConfiguration ¶
WaitForNginxConfiguration waits until the nginx configuration contains a particular configuration
func (*Framework) WaitForNginxCustomConfiguration ¶
func (f *Framework) WaitForNginxCustomConfiguration(from string, to string, matcher func(cfg string) bool)
WaitForNginxCustomConfiguration waits until the nginx configuration given part (from, to) contains a particular configuration
func (*Framework) WaitForNginxListening ¶
WaitForNginxListening waits until NGINX starts accepting connections on a port
type RequestScheme ¶
type RequestScheme string
RequestScheme define a scheme used in a test request.
const ( HTTP RequestScheme = "http" HTTPS RequestScheme = "https" )
These are valid test request schemes.
type TestContextType ¶
TestContextType describes the client context to use in communications with the Kubernetes API.
var TestContext TestContextType
TestContext is the global client context for tests.