Documentation ¶
Index ¶
- type Harness
- type Options
- type Test
- func (t *Test) Close()
- func (test *Test) CreateClusterRole(cr *rbacv1.ClusterRole)
- func (test *Test) CreateClusterRoleBinding(crb *rbacv1.ClusterRoleBinding)
- func (test *Test) CreateClusterRoleBindingFromFile(manifestPath string) *rbacv1.ClusterRoleBinding
- func (test *Test) CreateClusterRoleFromFile(manifestPath string) *rbacv1.ClusterRole
- func (test *Test) CreateConfigMap(namespace string, cm *v1.ConfigMap)
- func (test *Test) CreateConfigMapFromFile(namespace string, manifestPath string) *v1.ConfigMap
- func (test *Test) CreateDaemonSet(namespace string, d *appsv1.DaemonSet)
- func (test *Test) CreateDaemonSetFromFile(namespace string, manifestPath string) *appsv1.DaemonSet
- func (test *Test) CreateDeployment(namespace string, d *appsv1.Deployment)
- func (test *Test) CreateDeploymentFromFile(namespace string, manifestPath string) *appsv1.Deployment
- func (test *Test) CreateNamespace(name string)
- func (test *Test) CreateSecret(namespace string, secret *v1.Secret)
- func (test *Test) CreateSecretFromFile(namespace string, manifestPath string) *v1.Secret
- func (test *Test) CreateService(namespace string, service *v1.Service)
- func (test *Test) CreateServiceAccount(namespace string, serviceAccount *v1.ServiceAccount)
- func (test *Test) CreateServiceAccountFromFile(namespace string, manifestPath string) *v1.ServiceAccount
- func (test *Test) CreateServiceFromFile(namespace string, manifestPath string) *v1.Service
- func (t *Test) Debug(msg string)
- func (t *Test) Debugf(f string, args ...interface{})
- func (test *Test) DeleteClusterRole(cr *rbacv1.ClusterRole)
- func (test *Test) DeleteClusterRoleBinding(crb *rbacv1.ClusterRoleBinding)
- func (test *Test) DeleteConfigMap(ConfigMap *v1.ConfigMap)
- func (test *Test) DeleteDaemonSet(d *appsv1.DaemonSet)
- func (test *Test) DeleteDeployment(d *appsv1.Deployment)
- func (test *Test) DeleteNamespace(name string)
- func (test *Test) DeletePod(pod *v1.Pod)
- func (test *Test) DeleteSecret(secret *v1.Secret)
- func (test *Test) DeleteService(service *v1.Service)
- func (test *Test) DeleteServiceAccount(serviceAccount *v1.ServiceAccount)
- func (t *Test) DumpNamespace(w io.Writer, ns string)
- func (t *Test) DumpTestState(w io.Writer)
- func (test *Test) GetClusterRole(name string) (*rbacv1.ClusterRole, error)
- func (test *Test) GetClusterRoleBinding(name string) (*rbacv1.ClusterRoleBinding, error)
- func (test *Test) GetConfigMap(ns, name string) (*v1.ConfigMap, error)
- func (test *Test) GetDaemonSet(ns, name string) (*appsv1.DaemonSet, error)
- func (test *Test) GetDeployment(ns, name string) (*appsv1.Deployment, error)
- func (test *Test) GetNamespace(name string) (*v1.Namespace, error)
- func (test *Test) GetSecret(ns, name string) (*v1.Secret, error)
- func (test *Test) GetService(namespace, name string) *v1.Service
- func (test *Test) GetServiceAccount(namespace, name string) (*v1.ServiceAccount, error)
- func (t *Test) Info(msg string)
- func (t *Test) Infof(f string, args ...interface{})
- func (test *Test) ListNodes(options metav1.ListOptions) *v1.NodeList
- func (test *Test) ListPods(namespace string, options metav1.ListOptions) *v1.PodList
- func (test *Test) ListPodsFromDeployment(d *appsv1.Deployment) *v1.PodList
- func (test *Test) LoadClusterRole(manifestPath string) *rbacv1.ClusterRole
- func (test *Test) LoadClusterRoleBinding(manifestPath string) *rbacv1.ClusterRoleBinding
- func (test *Test) LoadConfigMap(manifestPath string) *v1.ConfigMap
- func (test *Test) LoadDaemonSet(manifestPath string) *appsv1.DaemonSet
- func (test *Test) LoadDeployment(manifestPath string) *appsv1.Deployment
- func (test *Test) LoadSecret(manifestPath string) *v1.Secret
- func (test *Test) LoadService(manifestPath string) *v1.Service
- func (test *Test) LoadServiceAccount(manifestPath string) *v1.ServiceAccount
- func (test *Test) NodeReady(node *v1.Node) bool
- func (test *Test) PodLogs(w io.Writer, pod *v1.Pod, containerName string) error
- func (test *Test) PodProxyGet(pod *v1.Pod, port, path string) *rest.Request
- func (test *Test) PodProxyGetJSON(pod *v1.Pod, port, path string, v interface{})
- func (test *Test) PodReady(pod v1.Pod) (bool, error)
- func (t *Test) Setup() *Test
- func (test *Test) UpdateService(service *v1.Service)
- func (test *Test) WaitForClusterRoleBindingReady(crb *rbacv1.ClusterRole, timeout time.Duration)
- func (test *Test) WaitForClusterRoleReady(cr *rbacv1.ClusterRole, timeout time.Duration)
- func (test *Test) WaitForConfigMapReady(cm *v1.ConfigMap, timeout time.Duration)
- func (test *Test) WaitForDaemonSetDeleted(d *appsv1.DaemonSet, timeout time.Duration)
- func (test *Test) WaitForDaemonSetReady(d *appsv1.DaemonSet, timeout time.Duration)
- func (test *Test) WaitForDeploymentDeleted(d *appsv1.Deployment, timeout time.Duration)
- func (test *Test) WaitForDeploymentReady(d *appsv1.Deployment, timeout time.Duration)
- func (test *Test) WaitForNodesReady(expectedNodes int, timeout time.Duration)
- func (test *Test) WaitForNodesReadyMin(minExpectedNodes int, timeout time.Duration)
- func (test *Test) WaitForPodsReady(namespace string, opts metav1.ListOptions, expectedReplicas int, ...) error
- func (test *Test) WaitForSecretReady(secret *v1.Secret, timeout time.Duration)
- func (test *Test) WaitForServiceAccountReady(serviceAccount *v1.ServiceAccount)
- func (test *Test) WaitForServiceDeleted(service *v1.Service)
- func (test *Test) WaitForServiceReady(service *v1.Service)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
Harness is a test harness for running integration tests on a kubernetes cluster.
func (*Harness) KubeClient ¶
func (h *Harness) KubeClient() kubernetes.Interface
KubeClient returns the underlying Kubernetes client hat be used to access the Kubernetes API directly.
func (*Harness) NewTest ¶
NewTest creates a new test. Call Close() to free kubernetes resources allocated during the test.
func (*Harness) SetKubeconfig ¶
SetKubeconfig reconfigures harness with the given kubeconfig file. Using "" as the new path makes harness fallback to the default kubeconfig location on your system.
type Options ¶
type Options struct { // Kubeconfig is the path to a kubeconfig file. If not given, Harness will // honour the KUBECONFIG environment variable and try to use // $HOME/.kube/config. Kubeconfig string // ManifestDirectory is the root directory where the test Kubernetes manifests // are located. It can be an absolute path a or path relative to the directory // where the test is. If not given, defaults to the current working directory. ManifestDirectory string // NoCleanup controls if tests should cleanup after them. NoCleanup bool // Logger is the Logger used to dispay test logs. If not given, Harness will // use logger.TestLogger which uses the logging built in the testing package. // This logger will only display logs on error or when -v is given to go test. // Additionally it will only dump the logs once the test has finished running. // // For writing and debugging long running tests, it is useful to have logs // being printed on stdout as it happens. logger.PrintfLogger can be used when // such behavior is needed. Logger logger.Logger // LogLevel controls how verbose the test logs are. Currently only Debug and // Info are available. If not given, defaults to Info. LogLevel logger.LogLevel }
Options are configuration options for the test harness.
type Test ¶
type Test struct { // ID is a unique identifier for the test, defined from the test function name. ID string // Namespace is name of the namespace automatically crafted by Setup for the // test to run in. Namespace string // contains filtered or unexported fields }
Test is a single test running in a kubernetes cluster.
func (*Test) Close ¶
func (t *Test) Close()
Close frees all kubernetes resources allocated during the test.
func (*Test) CreateClusterRole ¶
func (test *Test) CreateClusterRole(cr *rbacv1.ClusterRole)
CreateClusterRole creates a cluster role.
func (*Test) CreateClusterRoleBinding ¶
func (test *Test) CreateClusterRoleBinding(crb *rbacv1.ClusterRoleBinding)
CreateClusterRoleBinding creates a cluster role binding.
func (*Test) CreateClusterRoleBindingFromFile ¶
func (test *Test) CreateClusterRoleBindingFromFile(manifestPath string) *rbacv1.ClusterRoleBinding
CreateClusterRoleBindingFromFile creates a cluster role binding from a manifest file.
func (*Test) CreateClusterRoleFromFile ¶
func (test *Test) CreateClusterRoleFromFile(manifestPath string) *rbacv1.ClusterRole
CreateClusterRoleFromFile creates a cluster role from a manifest file.
func (*Test) CreateConfigMap ¶
CreateConfigMap creates a ConfigMap in the given namespace.
func (*Test) CreateConfigMapFromFile ¶
CreateConfigMapFromFile creates a ConfigMap from a manifest file in the given namespace.
func (*Test) CreateDaemonSet ¶
CreateDaemonSet creates a daemonset in the given namespace.
func (*Test) CreateDaemonSetFromFile ¶
CreateDaemonSetFromFile creates a daemonset from a manifest file in the given namespace.
func (*Test) CreateDeployment ¶
func (test *Test) CreateDeployment(namespace string, d *appsv1.Deployment)
CreateDeployment creates a deployment in the given namespace.
func (*Test) CreateDeploymentFromFile ¶
func (test *Test) CreateDeploymentFromFile(namespace string, manifestPath string) *appsv1.Deployment
CreateDeploymentFromFile creates a deployment from a manifest file in the given namespace.
func (*Test) CreateNamespace ¶
CreateNamespace creates a new namespace.
func (*Test) CreateSecret ¶
CreateSecret creates a secret in the given namespace.
func (*Test) CreateSecretFromFile ¶
CreateSecretFromFile creates a secret from a manifest file in the given namespace.
func (*Test) CreateService ¶
CreateService creates a service in the given namespace.
func (*Test) CreateServiceAccount ¶
func (test *Test) CreateServiceAccount(namespace string, serviceAccount *v1.ServiceAccount)
CreateServiceAccount creates a service account in the given namespace.
func (*Test) CreateServiceAccountFromFile ¶
func (test *Test) CreateServiceAccountFromFile(namespace string, manifestPath string) *v1.ServiceAccount
CreateServiceAccountFromFile creates a service account from a manifest file in the given namespace.
func (*Test) CreateServiceFromFile ¶
CreateServiceFromFile creates a service from a manifest file in the given namespace.
func (*Test) DeleteClusterRole ¶
func (test *Test) DeleteClusterRole(cr *rbacv1.ClusterRole)
DeleteClusterRole deletes a cluster role.
func (*Test) DeleteClusterRoleBinding ¶
func (test *Test) DeleteClusterRoleBinding(crb *rbacv1.ClusterRoleBinding)
DeleteClusterRoleBinding deletes a cluster role binding.
func (*Test) DeleteConfigMap ¶
DeleteConfigMap deletes a ConfigMap.
func (*Test) DeleteDaemonSet ¶
DeleteDaemonSet deletes a daemonset in the given namespace.
func (*Test) DeleteDeployment ¶
func (test *Test) DeleteDeployment(d *appsv1.Deployment)
DeleteDeployment deletes a deployment in the given namespace.
func (*Test) DeleteNamespace ¶
DeleteNamespace deletes a Namespace.
func (*Test) DeleteSecret ¶
DeleteSecret deletes a secret.
func (*Test) DeleteService ¶
DeleteService deletes a service.
func (*Test) DeleteServiceAccount ¶
func (test *Test) DeleteServiceAccount(serviceAccount *v1.ServiceAccount)
DeleteServiceAccount deletes a ServiceAccount.
func (*Test) DumpNamespace ¶
DumpNamespace writes to w information about the pods in a namespace.
func (*Test) DumpTestState ¶
DumpTestState writes to w information about the objects created by the test.
func (*Test) GetClusterRole ¶
func (test *Test) GetClusterRole(name string) (*rbacv1.ClusterRole, error)
GetClusterRole returns a ClusterRole object if it exists or error.
func (*Test) GetClusterRoleBinding ¶
func (test *Test) GetClusterRoleBinding(name string) (*rbacv1.ClusterRoleBinding, error)
GetClusterRoleBinding returns a ClusterRoleBinding object if it exists or error.
func (*Test) GetConfigMap ¶
GetConfigMap returns a ConfigMap object if it exists or error.
func (*Test) GetDaemonSet ¶
GetDaemonSet returns daemonset if it exists or error if it doesn't.
func (*Test) GetDeployment ¶
func (test *Test) GetDeployment(ns, name string) (*appsv1.Deployment, error)
GetDeployment returns Deployment if it exists or error if it doesn't.
func (*Test) GetNamespace ¶
GetNamespace returns a Namespace object if it exists or error.
func (*Test) GetService ¶
GetService retrieves a service with a given name and namespace.
func (*Test) GetServiceAccount ¶
func (test *Test) GetServiceAccount(namespace, name string) (*v1.ServiceAccount, error)
GetServiceAccount returns a ServiceAccount object if it exists or error.
func (*Test) ListNodes ¶
func (test *Test) ListNodes(options metav1.ListOptions) *v1.NodeList
ListNodes returns all nodes that are part of the cluster.
func (*Test) ListPodsFromDeployment ¶
func (test *Test) ListPodsFromDeployment(d *appsv1.Deployment) *v1.PodList
ListPodsFromDeployment returns the list of pods created by a deployment.
func (*Test) LoadClusterRole ¶
func (test *Test) LoadClusterRole(manifestPath string) *rbacv1.ClusterRole
LoadClusterRole loads a cluster role from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) LoadClusterRoleBinding ¶
func (test *Test) LoadClusterRoleBinding(manifestPath string) *rbacv1.ClusterRoleBinding
LoadClusterRoleBinding loads a cluster role binding from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) LoadConfigMap ¶
LoadConfigMap loads a ConfigMap from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) LoadDaemonSet ¶
LoadDaemonSet loads a daemonset from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) LoadDeployment ¶
func (test *Test) LoadDeployment(manifestPath string) *appsv1.Deployment
LoadDeployment loads a deployment from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) LoadSecret ¶
LoadSecret loads a secret from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) LoadService ¶
LoadService loads a service from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) LoadServiceAccount ¶
func (test *Test) LoadServiceAccount(manifestPath string) *v1.ServiceAccount
LoadServiceAccount loads a service account from a YAML manifest. The path to the manifest is relative to Harness.ManifestDirectory.
func (*Test) PodLogs ¶
PodLogs writes the container logs on w. If the pod has a single container, containerName is optional and can be set to "".
func (*Test) PodProxyGet ¶
PodProxyGet returns a Request that can used to perform an HTTP GET to a pod through the API server proxy. Port can be a port name or the port number.
If port is "", the first port found in the containers spec will be used.
func (*Test) PodProxyGetJSON ¶
PodProxyGetJSON is a convenience function around PodProxyGet that also unmarshals the response body into v.
func (*Test) PodReady ¶
PodReady returns whether a pod is running and each container has is in the ready state.
func (*Test) UpdateService ¶
UpdateService updates a service.
func (*Test) WaitForClusterRoleBindingReady ¶
func (test *Test) WaitForClusterRoleBindingReady(crb *rbacv1.ClusterRole, timeout time.Duration)
WaitForClusterRoleBindingReady waits until ClusterRoleBinding is created, otherwise times out.
func (*Test) WaitForClusterRoleReady ¶
func (test *Test) WaitForClusterRoleReady(cr *rbacv1.ClusterRole, timeout time.Duration)
WaitForClusterRoleReady waits until ClusterRole is created, otherwise times out.
func (*Test) WaitForConfigMapReady ¶
WaitForConfigMapReady waits until ConfigMap is created, otherwise times out.
func (*Test) WaitForDaemonSetDeleted ¶
WaitForDaemonSetDeleted waits until a deleted daemonset has disappeared from the cluster.
func (*Test) WaitForDaemonSetReady ¶
WaitForDaemonSetReady waits until all replica pods are running and ready.
func (*Test) WaitForDeploymentDeleted ¶
func (test *Test) WaitForDeploymentDeleted(d *appsv1.Deployment, timeout time.Duration)
WaitForDeploymentDeleted waits until a deleted deployment has disappeared from the cluster.
func (*Test) WaitForDeploymentReady ¶
func (test *Test) WaitForDeploymentReady(d *appsv1.Deployment, timeout time.Duration)
WaitForDeploymentReady waits until all replica pods are running and ready.
func (*Test) WaitForNodesReady ¶
WaitForNodesReady waits until the specified number of nodes are running and ready. The function waits until the exact number is of expected node is matched.
func (*Test) WaitForNodesReadyMin ¶
WaitForNodesReadyMin waits until the specified minimum number of nodes are running and ready. The function waits until the exact number is of expected node is matched.
func (*Test) WaitForPodsReady ¶
func (test *Test) WaitForPodsReady(namespace string, opts metav1.ListOptions, expectedReplicas int, timeout time.Duration) error
WaitForPodsReady waits for a selection of Pods to be running and each container to pass its readiness check.
func (*Test) WaitForSecretReady ¶
WaitForSecretReady waits until Secret is created, otherwise times out.
func (*Test) WaitForServiceAccountReady ¶
func (test *Test) WaitForServiceAccountReady(serviceAccount *v1.ServiceAccount)
WaitForServiceAccountReady waits until ConfigMap is created, otherwise times out.
func (*Test) WaitForServiceDeleted ¶
WaitForServiceDeleted waits until deleted service has disappeared from the cluster.
func (*Test) WaitForServiceReady ¶
WaitForServiceReady will wait until at least one endpoint backing up the service is ready.