environment

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

type Environment struct {
	Machine
	testing.Catalog

	Log          *zap.SugaredLogger
	Config       *config.Config
	ObservedLogs *observer.ObservedLogs
	Namespace    string
	// contains filtered or unexported fields
}

Environment starts our operator and handles interaction with the k8s cluster used in the tests

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment returns a new struct

func (*Environment) AllLogMessages

func (e *Environment) AllLogMessages() (msgs []string)

AllLogMessages returns only the message part of existing logs to aid in debugging

func (*Environment) FlushLog

func (e *Environment) FlushLog() error

FlushLog flushes the zap log

func (*Environment) Setup

func (e *Environment) Setup() (StopFunc, error)

Setup prepares the test environment by loading config and finally starting the operator

type Machine

type Machine struct {
	Clientset          *kubernetes.Clientset
	VersionedClientset *versioned.Clientset
	// contains filtered or unexported fields
}

Machine produces and destroys resources for tests

func (*Machine) CollectJobs

func (m *Machine) CollectJobs(namespace string, labels string, n int) ([]batchv1.Job, error)

CollectJobs waits for n jobs with specified labels. It fails after the timeout.

func (*Machine) CollectSecret

func (m *Machine) CollectSecret(namespace string, name string) (*corev1.Secret, error)

CollectSecret polls untile the specified secret can be fetched

func (*Machine) ContainExpectedEvent

func (m *Machine) ContainExpectedEvent(events []corev1.Event, reason string, message string) bool

ContainExpectedEvent return true if events contain target resource event

func (*Machine) ContainJob

func (m *Machine) ContainJob(jobs []batchv1.Job, name string) bool

ContainJob searches job array for a job matching `name`

func (*Machine) CreateBOSHDeployment

func (m *Machine) CreateBOSHDeployment(namespace string, deployment bdcv1.BOSHDeployment) (*bdcv1.BOSHDeployment, TearDownFunc, error)

CreateBOSHDeployment creates a BOSHDeployment custom resource and returns a function to delete it

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) CreateExtendedJob

func (m *Machine) CreateExtendedJob(namespace string, job ejv1.ExtendedJob) (*ejv1.ExtendedJob, TearDownFunc, error)

CreateExtendedJob creates an ExtendedJob

func (*Machine) CreateExtendedSecret

func (m *Machine) CreateExtendedSecret(namespace string, es esv1.ExtendedSecret) (*esv1.ExtendedSecret, TearDownFunc, error)

CreateExtendedSecret creates a ExtendedSecret custom resource and returns a function to delete it

func (*Machine) CreateExtendedStatefulSet

func (m *Machine) CreateExtendedStatefulSet(namespace string, ess essv1.ExtendedStatefulSet) (*essv1.ExtendedStatefulSet, TearDownFunc, error)

CreateExtendedStatefulSet creates a ExtendedStatefulSet custom resource and returns a function to delete it

func (*Machine) CreatePod

func (m *Machine) CreatePod(namespace string, pod corev1.Pod) (TearDownFunc, error)

CreatePod creates a default pod and returns a function to delete it

func (*Machine) CreateSecret

func (m *Machine) CreateSecret(namespace string, secret corev1.Secret) (TearDownFunc, error)

CreateSecret creates a secret and returns a function to delete it

func (*Machine) DeleteBOSHDeployment

func (m *Machine) DeleteBOSHDeployment(namespace string, name string) error

DeleteBOSHDeployment deletes a BOSHDeployment custom resource

func (*Machine) DeleteExtendedSecret

func (m *Machine) DeleteExtendedSecret(namespace string, name string) error

DeleteExtendedSecret deletes an ExtendedSecret custom resource

func (*Machine) DeleteExtendedStatefulSet

func (m *Machine) DeleteExtendedStatefulSet(namespace string, name string) error

DeleteExtendedStatefulSet deletes a ExtendedStatefulSet custom resource

func (*Machine) DeleteJobs

func (m *Machine) DeleteJobs(namespace string, labels string) (bool, error)

DeleteJobs deletes all the jobs

func (*Machine) ExtendedJobExists

func (m *Machine) ExtendedJobExists(namespace string, name string) (bool, error)

ExtendedJobExists returns true if extended job with that name exists

func (*Machine) ExtendedStatefulSetAvailable

func (m *Machine) ExtendedStatefulSetAvailable(namespace string, name string, version int) (bool, error)

ExtendedStatefulSetAvailable returns true if current version is available

func (*Machine) ExtendedStatefulSetExists

func (m *Machine) ExtendedStatefulSetExists(namespace string, labels string) (bool, error)

ExtendedStatefulSetExists returns true if at least one ess selected by labels exists

func (*Machine) GetBOSHDeployment

func (m *Machine) GetBOSHDeployment(namespace string, name string) (*bdcv1.BOSHDeployment, error)

GetBOSHDeployment gets a BOSHDeployment custom resource

func (*Machine) GetBOSHDeploymentEvents

func (m *Machine) GetBOSHDeploymentEvents(namespace string, name string, id string) ([]corev1.Event, error)

GetBOSHDeploymentEvents gets target resource events

func (*Machine) GetConfigMap

func (m *Machine) GetConfigMap(namespace string, name string) (*corev1.ConfigMap, error)

GetConfigMap gets a ConfigMap by name

func (*Machine) GetExtendedJob

func (m *Machine) GetExtendedJob(namespace string, name string) (*ejv1.ExtendedJob, error)

GetExtendedJob gets an ExtendedJob custom resource

func (*Machine) GetExtendedStatefulSet

func (m *Machine) GetExtendedStatefulSet(namespace string, name string) (*essv1.ExtendedStatefulSet, error)

GetExtendedStatefulSet gets a ExtendedStatefulSet custom resource

func (*Machine) GetPod

func (m *Machine) GetPod(namespace string, name string) (*corev1.Pod, error)

GetPod returns pod by name

func (*Machine) GetPodLogs

func (m *Machine) GetPodLogs(namespace, podName string) (string, error)

GetPodLogs gets pod logs

func (*Machine) GetPods

func (m *Machine) GetPods(namespace string, labels string) (*corev1.PodList, error)

GetPods returns all the pods selected by labels

func (*Machine) GetSecret

func (m *Machine) GetSecret(namespace string, name string) (*corev1.Secret, error)

GetSecret fetches the specified secret

func (*Machine) GetService added in v0.2.0

func (m *Machine) GetService(namespace string, name string) (*corev1.Service, error)

GetService gets target Service

func (*Machine) GetStatefulSet

func (m *Machine) GetStatefulSet(namespace string, name string) (*v1beta1.StatefulSet, error)

GetStatefulSet gets a StatefulSet custom resource

func (*Machine) HasBOSHDeployment

func (m *Machine) HasBOSHDeployment(namespace string, name string) (bool, error)

HasBOSHDeployment returns true if the pod by that name is in state running

func (*Machine) HasBOSHDeploymentEvent

func (m *Machine) HasBOSHDeploymentEvent(namespace string, fieldSelector string) (bool, error)

HasBOSHDeploymentEvent returns true if the pod by that name is in state running

func (*Machine) JobExists

func (m *Machine) JobExists(namespace string, name string) (bool, error)

JobExists returns true if job with that name exists

func (*Machine) PVAvailable

func (m *Machine) PVAvailable(name string) (bool, error)

PVAvailable returns true if the pv by that name is in state available

func (*Machine) PVCsDeleted

func (m *Machine) PVCsDeleted(namespace string) (bool, error)

PVCsDeleted returns true if the all pvs are deleted

func (*Machine) PVsDeleted

func (m *Machine) PVsDeleted(labels string) (bool, error)

PVsDeleted returns true if the all pvs are deleted

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

func (m *Machine) PodRunning(namespace string, name string) (bool, error)

PodRunning returns true if the pod by that name is in state running

func (*Machine) PodsDeleted

func (m *Machine) PodsDeleted(namespace string) (bool, error)

PodsDeleted returns true if the all pods are deleted

func (*Machine) PodsFailing

func (m *Machine) PodsFailing(namespace string, labels string) (bool, error)

PodsFailing returns true if the pod by that name exist and is in a failed state

func (*Machine) PodsRunning

func (m *Machine) PodsRunning(namespace string, labels string) (bool, error)

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

func (m *Machine) SecretExists(namespace string, name string) (bool, error)

SecretExists returns true if the pod by that name is in state running

func (*Machine) StatefulSetNewGeneration

func (m *Machine) StatefulSetNewGeneration(namespace string, name string, version int64) (bool, error)

StatefulSetNewGeneration returns true if StatefulSet has new generation

func (*Machine) StatefulSetRunning

func (m *Machine) StatefulSetRunning(namespace string, name string) (bool, error)

StatefulSetRunning returns true if the statefulset by that name has all pods created

func (*Machine) TearDownAll

func (m *Machine) TearDownAll(funcs []TearDownFunc) error

TearDownAll calls all passed in tear down functions in order

func (*Machine) UpdateBOSHDeployment

func (m *Machine) UpdateBOSHDeployment(namespace string, deployment bdcv1.BOSHDeployment) (*bdcv1.BOSHDeployment, TearDownFunc, error)

UpdateBOSHDeployment creates a BOSHDeployment custom resource and returns a function to delete it

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) UpdateExtendedJob

func (m *Machine) UpdateExtendedJob(namespace string, eJob ejv1.ExtendedJob) error

UpdateExtendedJob updates an extended job

func (*Machine) UpdateExtendedStatefulSet

func (m *Machine) UpdateExtendedStatefulSet(namespace string, ess essv1.ExtendedStatefulSet) (*essv1.ExtendedStatefulSet, TearDownFunc, error)

UpdateExtendedStatefulSet creates a ExtendedStatefulSet custom resource 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) WaitForBOSHDeploymentDeletion

func (m *Machine) WaitForBOSHDeploymentDeletion(namespace string, name string) error

WaitForBOSHDeploymentDeletion blocks until the CR is deleted

func (*Machine) WaitForBOSHDeploymentEvent

func (m *Machine) WaitForBOSHDeploymentEvent(namespace string, fieldSelector string) error

WaitForBOSHDeploymentEvent gets desired event

func (*Machine) WaitForExtendedJobDeletion

func (m *Machine) WaitForExtendedJobDeletion(namespace string, name string) error

WaitForExtendedJobDeletion blocks until the CR job is deleted

func (*Machine) WaitForExtendedStatefulSetAvailable

func (m *Machine) WaitForExtendedStatefulSetAvailable(namespace string, name string, version int) error

WaitForExtendedStatefulSetAvailable blocks until latest version is available. It fails after the timeout.

func (*Machine) WaitForExtendedStatefulSets

func (m *Machine) WaitForExtendedStatefulSets(namespace string, labels string) error

WaitForExtendedStatefulSets blocks until at least one ExtendedStatefulSet is found. It fails after the timeout.

func (*Machine) WaitForJobDeletion

func (m *Machine) WaitForJobDeletion(namespace string, name string) error

WaitForJobDeletion blocks until the batchv1.Job is deleted

func (*Machine) WaitForJobExists

func (m *Machine) WaitForJobExists(namespace string, labels string) (bool, error)

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

func (m *Machine) WaitForJobsDeleted(namespace string, labels string) error

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) WaitForPV

func (m *Machine) WaitForPV(name string) error

WaitForPV blocks until the pv is running. It fails after the timeout.

func (*Machine) WaitForPVCsDelete

func (m *Machine) WaitForPVCsDelete(namespace string) error

WaitForPVCsDelete blocks until the pvc is deleted. It fails after the timeout.

func (*Machine) WaitForPVsDelete

func (m *Machine) WaitForPVsDelete(labels string) error

WaitForPVsDelete blocks until the pv is deleted. It fails after the timeout.

func (*Machine) WaitForPod

func (m *Machine) WaitForPod(namespace string, name string) error

WaitForPod blocks until the pod is running. It fails after the timeout.

func (*Machine) WaitForPodFailures

func (m *Machine) WaitForPodFailures(namespace string, labels string) error

WaitForPodFailures blocks until all selected pods are failing. It fails after the timeout.

func (*Machine) WaitForPods

func (m *Machine) WaitForPods(namespace string, labels string) error

WaitForPods blocks until all selected pods are running. It fails after the timeout.

func (*Machine) WaitForPodsDelete

func (m *Machine) WaitForPodsDelete(namespace string) error

WaitForPodsDelete blocks until the pod is deleted. It fails after the timeout.

func (*Machine) WaitForSecret

func (m *Machine) WaitForSecret(namespace string, name string) error

WaitForSecret blocks until the secret is available. It fails after the timeout.

func (*Machine) WaitForSecretDeletion

func (m *Machine) WaitForSecretDeletion(namespace string, name string) error

WaitForSecretDeletion blocks until the CR is deleted

func (*Machine) WaitForStatefulSet

func (m *Machine) WaitForStatefulSet(namespace string, labels string) error

WaitForStatefulSet blocks until all statefulset pods are running. It fails after the timeout.

func (*Machine) WaitForStatefulSetNewGeneration

func (m *Machine) WaitForStatefulSetNewGeneration(namespace string, name string, currentVersion int64) error

WaitForStatefulSetNewGeneration blocks until at least one StatefulSet is found. It fails after the timeout.

type StopFunc

type StopFunc func()

StopFunc is used to clean up the environment

type TearDownFunc

type TearDownFunc func() error

TearDownFunc tears down the resource

Jump to

Keyboard shortcuts

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