Documentation ¶
Overview ¶
Package machine builds k8s resources for use in integration tests
Index ¶
- Constants
- type ChanResult
- type Machine
- func (m *Machine) CollectJobs(namespace string, labels string, n int) ([]batchv1.Job, error)
- func (m *Machine) CollectSecret(namespace string, name string) (*corev1.Secret, error)
- func (m *Machine) ConfigMapExists(namespace string, name string) (bool, error)
- func (m *Machine) ContainExpectedEvent(events []corev1.Event, reason string, message string) bool
- func (m *Machine) ContainJob(jobs []batchv1.Job, name string) bool
- func (m *Machine) CreateConfigMap(namespace string, configMap corev1.ConfigMap) (TearDownFunc, error)
- func (m *Machine) CreateEndpoints(namespace string, ep corev1.Endpoints) (TearDownFunc, error)
- func (m *Machine) CreateLabeledNamespace(namespace string, labels map[string]string) (TearDownFunc, error)
- func (m *Machine) CreateNamespace(namespace string) (TearDownFunc, error)
- func (m *Machine) CreatePod(namespace string, pod corev1.Pod) (TearDownFunc, error)
- func (m *Machine) CreateSecret(namespace string, secret corev1.Secret) (TearDownFunc, error)
- func (m *Machine) CreateService(namespace string, service corev1.Service) (TearDownFunc, error)
- func (m *Machine) DeleteJobs(namespace string, labels string) (bool, error)
- func (m *Machine) DeleteNamespace(namespace string) error
- func (m *Machine) DeleteSecrets(namespace string) (bool, error)
- func (m *Machine) GetConfigMap(namespace string, name string) (*corev1.ConfigMap, error)
- func (m *Machine) GetEndpoints(namespace string, name string) (*corev1.Endpoints, error)
- func (m *Machine) GetNodes() ([]corev1.Node, error)
- func (m *Machine) GetPod(namespace string, name string) (*corev1.Pod, error)
- func (m *Machine) GetPodContainerLogs(namespace, podName, containerName string) (string, error)
- func (m *Machine) GetPodLogs(namespace, podName string) (string, error)
- func (m *Machine) GetPods(namespace string, labels string) (*corev1.PodList, error)
- func (m *Machine) GetSecret(namespace string, name string) (*corev1.Secret, error)
- func (m *Machine) GetService(namespace string, name string) (*corev1.Service, error)
- func (m *Machine) InitContainerRunning(namespace, podName, containerName string) (bool, error)
- func (m *Machine) JobExists(namespace string, name string) (bool, error)
- func (m *Machine) PodContainsLogMsg(namespace, podName, containerName, msg string) error
- func (m *Machine) PodCount(namespace string, labels string, match func(corev1.Pod) bool) (int, error)
- func (m *Machine) PodLabeled(namespace string, name string, desiredLabel, desiredValue string) (bool, error)
- func (m *Machine) PodReady(namespace string, name string) (bool, error)
- func (m *Machine) PodRunning(namespace string, name string) (bool, error)
- func (m *Machine) PodsDeleted(namespace string) (bool, error)
- func (m *Machine) PodsFailing(namespace string, labels string) (bool, error)
- func (m *Machine) PodsRunning(namespace string, labels string) (bool, error)
- func (m *Machine) SecretExists(namespace string, name string) (bool, error)
- func (m *Machine) SubsetsExist(namespace string, endpointsName string) (bool, error)
- func (m *Machine) TearDownAll(funcs []TearDownFunc) error
- func (m *Machine) UpdateConfigMap(namespace string, configMap corev1.ConfigMap) (*corev1.ConfigMap, TearDownFunc, error)
- func (m *Machine) UpdateEndpoints(namespace string, ep corev1.Endpoints) (*corev1.Endpoints, TearDownFunc, error)
- func (m *Machine) UpdatePod(namespace string, pod corev1.Pod) (*corev1.Pod, TearDownFunc, error)
- func (m *Machine) UpdateSecret(namespace string, secret corev1.Secret) (*corev1.Secret, TearDownFunc, error)
- func (m *Machine) UpdateService(namespace string, svc corev1.Service) (*corev1.Service, TearDownFunc, error)
- func (m *Machine) WaitForConfigMap(namespace string, name string) error
- func (m *Machine) WaitForInitContainerRunning(namespace, podName, containerName string) error
- func (m *Machine) WaitForJobDeletion(namespace string, name string) error
- func (m *Machine) WaitForJobExists(namespace string, labels string) (bool, error)
- func (m *Machine) WaitForJobsDeleted(namespace string, labels string) error
- func (m *Machine) WaitForLogMsg(logs *observer.ObservedLogs, msg string) error
- func (m *Machine) WaitForPod(namespace string, name string) error
- func (m *Machine) WaitForPodContainerLogMatchRegexp(namespace string, podName string, containerName string, regExp string) error
- func (m *Machine) WaitForPodContainerLogMsg(namespace, podName, containerName, msg string) error
- func (m *Machine) WaitForPodCount(namespace string, labels string, count int) error
- func (m *Machine) WaitForPodFailures(namespace string, labels string) error
- func (m *Machine) WaitForPodLogMatchRegexp(namespace string, podName string, regExp string) error
- func (m *Machine) WaitForPodLogMsg(namespace string, podName string, msg string) error
- func (m *Machine) WaitForPodReady(namespace string, name string) error
- func (m *Machine) WaitForPods(namespace string, labels string) error
- func (m *Machine) WaitForPodsDelete(namespace string) error
- func (m *Machine) WaitForPortReachable(protocol, uri string) error
- func (m *Machine) WaitForSecret(namespace string, name string) error
- func (m *Machine) WaitForSecretChange(namespace string, name string, changed SecretChangedFunc) error
- func (m *Machine) WaitForSecretDeletion(namespace string, name string) error
- func (m *Machine) WaitForServiceAccount(namespace string, name string) error
- func (m *Machine) WaitForSubsetsExist(namespace string, endpointsName string) error
- type SecretChangedFunc
- type TearDownFunc
Constants ¶
const ( // DefaultTimeout used to wait for resources DefaultTimeout = 300 * time.Second // DefaultInterval for polling DefaultInterval = 500 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChanResult ¶
type ChanResult struct {
Error error
}
ChanResult holds different fields that can be sent through a channel
type Machine ¶
type Machine struct { PollTimeout time.Duration PollInterval time.Duration Clientset *kubernetes.Clientset }
Machine produces and destroys resources for tests
func NewMachine ¶
func NewMachine() Machine
NewMachine returns a new machine which creates k8s resources
func (*Machine) CollectJobs ¶
CollectJobs waits for n jobs with specified labels. It fails after the timeout.
func (*Machine) CollectSecret ¶
CollectSecret polls until the specified secret can be fetched
func (*Machine) ConfigMapExists ¶
ConfigMapExists returns true if the secret by that name exist
func (*Machine) ContainExpectedEvent ¶
ContainExpectedEvent return true if events contain target resource event
func (*Machine) ContainJob ¶
ContainJob searches job array for a job matching `name`
func (*Machine) CreateConfigMap ¶
func (m *Machine) CreateConfigMap(namespace string, configMap corev1.ConfigMap) (TearDownFunc, error)
CreateConfigMap creates a ConfigMap and returns a function to delete it
func (*Machine) CreateEndpoints ¶
CreateEndpoints creates an Endpoint in the given namespace
func (*Machine) CreateLabeledNamespace ¶
func (m *Machine) CreateLabeledNamespace(namespace string, labels map[string]string) (TearDownFunc, error)
CreateLabeledNamespace creates a namespace, it doesn't return an error if the namespace exists
func (*Machine) CreateNamespace ¶
func (m *Machine) CreateNamespace(namespace string) (TearDownFunc, error)
CreateNamespace creates a namespace, it doesn't return an error if the namespace exists
func (*Machine) CreateSecret ¶
CreateSecret creates a secret and returns a function to delete it
func (*Machine) CreateService ¶
CreateService creates a Service in the given namespace
func (*Machine) DeleteJobs ¶
DeleteJobs deletes all the jobs
func (*Machine) DeleteNamespace ¶
DeleteNamespace deletes a namespace, it returns an error if it fails
func (*Machine) DeleteSecrets ¶
DeleteSecrets deletes all the secrets
func (*Machine) GetConfigMap ¶
GetConfigMap gets a ConfigMap by name
func (*Machine) GetEndpoints ¶
GetEndpoints gets target Endpoints
func (*Machine) GetPodContainerLogs ¶
GetPodContainerLogs gets logs for a specific container in a pd
func (*Machine) GetPodLogs ¶
GetPodLogs gets pod logs
func (*Machine) GetService ¶
GetService gets target Service
func (*Machine) InitContainerRunning ¶
InitContainerRunning returns true if the pod by that name has a specific init container that is in state running
func (*Machine) PodContainsLogMsg ¶
PodContainsLogMsg searches pod test logs for at least one occurrence of msg, but it will have a shorter timeout(10secs). This is for tests where one does not expect to see a log.
func (*Machine) PodCount ¶
func (m *Machine) PodCount(namespace string, labels string, match func(corev1.Pod) bool) (int, error)
PodCount returns the number of matching pods
func (*Machine) PodLabeled ¶
func (m *Machine) PodLabeled(namespace string, name string, desiredLabel, desiredValue string) (bool, error)
PodLabeled returns true if the pod is labeled correctly
func (*Machine) PodRunning ¶
PodRunning returns true if the pod by that name is in state running
func (*Machine) PodsDeleted ¶
PodsDeleted returns true if the all pods are deleted
func (*Machine) PodsFailing ¶
PodsFailing returns true if the pod by that name exist and is in a failed state
func (*Machine) PodsRunning ¶
PodsRunning returns true if all the pods selected by labels are in state running Note that only the first page of pods is considered - don't use this if you have a long pod list that you care about
func (*Machine) SecretExists ¶
SecretExists returns true if the secret by that name exist
func (*Machine) SubsetsExist ¶
SubsetsExist checks if the subsets of the endpoints exist
func (*Machine) TearDownAll ¶
func (m *Machine) TearDownAll(funcs []TearDownFunc) error
TearDownAll calls all passed in tear down functions in order
func (*Machine) UpdateConfigMap ¶
func (m *Machine) UpdateConfigMap(namespace string, configMap corev1.ConfigMap) (*corev1.ConfigMap, TearDownFunc, error)
UpdateConfigMap updates a ConfigMap and returns a function to delete it
func (*Machine) UpdateEndpoints ¶
func (m *Machine) UpdateEndpoints(namespace string, ep corev1.Endpoints) (*corev1.Endpoints, TearDownFunc, error)
UpdateEndpoints updates an endpoint and returns a function to delete it
func (*Machine) UpdateSecret ¶
func (m *Machine) UpdateSecret(namespace string, secret corev1.Secret) (*corev1.Secret, TearDownFunc, error)
UpdateSecret updates a secret and returns a function to delete it
func (*Machine) UpdateService ¶
func (m *Machine) UpdateService(namespace string, svc corev1.Service) (*corev1.Service, TearDownFunc, error)
UpdateService updates a service and returns a function to delete it
func (*Machine) WaitForConfigMap ¶
WaitForConfigMap blocks until the config map is available. It fails after the timeout.
func (*Machine) WaitForInitContainerRunning ¶
WaitForInitContainerRunning blocks until a pod's init container is running. It fails after the timeout.
func (*Machine) WaitForJobDeletion ¶
WaitForJobDeletion blocks until the batchv1.Job is deleted
func (*Machine) WaitForJobExists ¶
WaitForJobExists polls until a short timeout is reached or a job is found It returns true only if a job is found
func (*Machine) WaitForJobsDeleted ¶
WaitForJobsDeleted waits until the jobs no longer exists
func (*Machine) WaitForLogMsg ¶
func (m *Machine) WaitForLogMsg(logs *observer.ObservedLogs, msg string) error
WaitForLogMsg searches zap test logs for at least one occurrence of msg. When using this, tests should use FlushLog() to remove log messages from other tests.
func (*Machine) WaitForPod ¶
WaitForPod blocks until the pod is running. It fails after the timeout.
func (*Machine) WaitForPodContainerLogMatchRegexp ¶
func (m *Machine) WaitForPodContainerLogMatchRegexp(namespace string, podName string, containerName string, regExp string) error
WaitForPodContainerLogMatchRegexp searches a pod's container test logs for at least one occurrence of Regexp.
func (*Machine) WaitForPodContainerLogMsg ¶
WaitForPodContainerLogMsg searches pod test logs for at least one occurrence of msg.
func (*Machine) WaitForPodCount ¶ added in v0.0.2
WaitForPodCount blocks until the specified number of pods is running
func (*Machine) WaitForPodFailures ¶
WaitForPodFailures blocks until all selected pods are failing. It fails after the timeout.
func (*Machine) WaitForPodLogMatchRegexp ¶
WaitForPodLogMatchRegexp searches pod test logs for at least one occurrence of Regexp.
func (*Machine) WaitForPodLogMsg ¶
WaitForPodLogMsg searches pod test logs for at least one occurrence of msg.
func (*Machine) WaitForPodReady ¶
WaitForPodReady blocks until the pod is ready. It fails after the timeout.
func (*Machine) WaitForPods ¶
WaitForPods blocks until all selected pods are running. It fails after the timeout.
func (*Machine) WaitForPodsDelete ¶
WaitForPodsDelete blocks until the pod is deleted. It fails after the timeout.
func (*Machine) WaitForPortReachable ¶
WaitForPortReachable blocks until the endpoint is reachable
func (*Machine) WaitForSecret ¶
WaitForSecret blocks until the secret is available. It fails after the timeout.
func (*Machine) WaitForSecretChange ¶
func (m *Machine) WaitForSecretChange(namespace string, name string, changed SecretChangedFunc) error
WaitForSecretChange blocks until the secret fulfills the change func
func (*Machine) WaitForSecretDeletion ¶
WaitForSecretDeletion blocks until the resource is deleted
func (*Machine) WaitForServiceAccount ¶ added in v0.0.2
WaitForServiceAccount blocks until the service account exists
type SecretChangedFunc ¶
SecretChangedFunc returns true if something changed in the secret