environment

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyCRDs added in v0.4.2

func ApplyCRDs(kubeConfig *rest.Config) error

ApplyCRDs applies the CRDs to the cluster

func KubeConfig added in v0.4.2

func KubeConfig() (*rest.Config, error)

KubeConfig returns a kube config for this environment

Types

type ChanResult added in v0.3.1

type ChanResult struct {
	Error error
}

ChanResult holds different fields that can be sent through a channel

type Environment

type Environment struct {
	Machine
	testing.Catalog

	ID           int
	Teardown     func(wasFailure bool)
	KubeConfig   *rest.Config
	Log          *zap.SugaredLogger
	Config       *config.Config
	ObservedLogs *observer.ObservedLogs
	Namespace    string
	Stop         chan struct{}
	// contains filtered or unexported fields
}

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

func NewEnvironment

func NewEnvironment(kubeConfig *rest.Config) *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) NodeIP added in v0.4.2

func (e *Environment) NodeIP() (string, error)

NodeIP returns a public IP of a node

func (*Environment) SetupClientsets added in v0.4.2

func (e *Environment) SetupClientsets() error

SetupClientsets initializes kube clientsets

func (*Environment) SetupLoggerContext added in v0.4.2

func (e *Environment) SetupLoggerContext(prefix string) context.Context

SetupLoggerContext sets up the logger and puts it into a new context

func (*Environment) SetupNamespace added in v0.4.2

func (e *Environment) SetupNamespace() error

SetupNamespace creates the namespace and the clientsets and prepares the teardowm

func (*Environment) StartOperator added in v0.4.2

func (e *Environment) StartOperator() error

StartOperator prepares and starts the cf-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) CheckExtendedStatefulSet added in v0.2.2

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

CheckExtendedStatefulSet checks extendedstatefulset according to the version

func (*Machine) CheckExtendedStatefulSetVersion added in v0.2.2

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

CheckExtendedStatefulSetVersion returns true if the version status is true

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 bdv1.BOSHDeployment) (*bdv1.BOSHDeployment, TearDownFunc, error)

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

func (*Machine) CreateBOSHDeploymentUsingChan added in v0.3.1

func (m *Machine) CreateBOSHDeploymentUsingChan(outputChannel chan ChanResult, namespace string, deployment bdv1.BOSHDeployment)

CreateBOSHDeploymentUsingChan creates a BOSHDeployment custom resource and returns an error via a channel

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 esv1.ExtendedStatefulSet) (*esv1.ExtendedStatefulSet, TearDownFunc, error)

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

func (*Machine) CreateNamespace added in v0.2.2

func (m *Machine) CreateNamespace(namespace string) (TearDownFunc, error)

CreateNamespace creates a namespace, it doesn't return an error if the namespace exists

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) CreatePodWithTailLogsContainer added in v0.4.0

func (m *Machine) CreatePodWithTailLogsContainer(podName string, parentPodCmd string, parentCName string, sidecardCName string,
	dockerImg string) corev1.Pod

CreatePodWithTailLogsContainer will generate a pod with two containers One is the parent container that will execute a cmd, preferrable something that writes into files under /var/vcap/sys/log The side-car container, will be tailing the logs of specific files under /var/vcap/sys/log, by running the cf-operator util tail-logs subcmommand

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) CreateService added in v0.4.2

func (m *Machine) CreateService(namespace string, service corev1.Service) (TearDownFunc, error)

CreateService creates a Service in the given namespace

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) DeleteSecrets added in v0.3.0

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

DeleteSecrets deletes all the secrets

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) (*bdv1.BOSHDeployment, error)

GetBOSHDeployment gets a BOSHDeployment custom resource

func (*Machine) GetConfigMap

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

GetConfigMap gets a ConfigMap by name

func (*Machine) GetEndpoints added in v0.2.1

func (m *Machine) GetEndpoints(namespace string, name string) (*corev1.Endpoints, error)

GetEndpoints gets target Endpoints

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) (*esv1.ExtendedStatefulSet, error)

GetExtendedStatefulSet gets a ExtendedStatefulSet custom resource

func (*Machine) GetInstanceGroupPods added in v0.3.0

func (m *Machine) GetInstanceGroupPods(namespace string, deployment string, igName string, version string) (*corev1.PodList, error)

GetInstanceGroupPods returns all pods from a specific instance group version

func (*Machine) GetNodes added in v0.3.1

func (m *Machine) GetNodes() ([]corev1.Node, error)

GetNodes gets nodes

func (*Machine) GetPod

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

GetPod returns pod by name

func (*Machine) GetPodContainerLogs added in v0.3.0

func (m *Machine) GetPodContainerLogs(namespace, podName, containerName string) (string, error)

GetPodContainerLogs gets logs for a specific container in a pd

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) InitContainerRunning added in v0.3.1

func (m *Machine) InitContainerRunning(namespace, podName, containerName string) (bool, error)

InitContainerRunning returns true if the pod by that name has a specific init container that 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) PodContainsLogMsg added in v0.4.0

func (m *Machine) PodContainsLogMsg(namespace, podName, containerName, msg string) error

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 added in v0.3.0

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) PodReady added in v0.4.0

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

PodReady returns true if the pod by that name is ready.

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 secret by that name exist

func (*Machine) StatefulSetExist added in v0.2.1

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

StatefulSetExist checks if the statefulset exists

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) SubsetsExist added in v0.2.1

func (m *Machine) SubsetsExist(namespace string, endpointsName string) (bool, error)

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

func (m *Machine) UpdateBOSHDeployment(namespace string, deployment bdv1.BOSHDeployment) (*bdv1.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 esv1.ExtendedStatefulSet) (*esv1.ExtendedStatefulSet, TearDownFunc, error)

UpdateExtendedStatefulSet updates 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) 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) WaitForInitContainerRunning added in v0.3.1

func (m *Machine) WaitForInitContainerRunning(namespace, podName, containerName string) error

WaitForInitContainerRunning blocks until a pod's init container is running. It fails after the timeout.

func (*Machine) WaitForInstanceGroup added in v0.3.0

func (m *Machine) WaitForInstanceGroup(namespace string, deployment string, igName string, version string, count int) error

WaitForInstanceGroup blocks until all selected pods of the instance group are running. 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) WaitForPodContainerLogMatchRegexp added in v0.3.1

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 added in v0.3.0

func (m *Machine) WaitForPodContainerLogMsg(namespace, podName, containerName, msg string) error

WaitForPodContainerLogMsg searches pod test logs for at least one occurrence of msg.

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) WaitForPodLogMatchRegexp added in v0.2.1

func (m *Machine) WaitForPodLogMatchRegexp(namespace string, podName string, regExp string) error

WaitForPodLogMatchRegexp searches pod test logs for at least one occurrence of Regexp.

func (*Machine) WaitForPodLogMsg added in v0.2.1

func (m *Machine) WaitForPodLogMsg(namespace string, podName string, msg string) error

WaitForPodLogMsg searches pod test logs for at least one occurrence of msg.

func (*Machine) WaitForPodReady added in v0.4.0

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

WaitForPodReady blocks until the pod is ready. 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) WaitForPortReachable added in v0.4.2

func (m *Machine) WaitForPortReachable(protocol, uri string) error

WaitForPortReachable blocks until the endpoint is reachable

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) WaitForStatefulSetDelete added in v0.2.1

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

WaitForStatefulSetDelete blocks until the specified statefulset is deleted

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.

func (*Machine) WaitForSubsetsExist added in v0.2.1

func (m *Machine) WaitForSubsetsExist(namespace string, endpointsName string) error

WaitForSubsetsExist blocks until the specified endpoints' subsets exist

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