Documentation
¶
Overview ¶
Package helper contains various helpers for use in end-to-end testing.
Index ¶
- Constants
- Variables
- func AddLoopbackTestHostnameLabel(c *coh.Coherence)
- func AssertCoherenceJobs(ctx TestContext, t *testing.T, yamlFile string) (map[string]coh.CoherenceJob, []corev1.Pod)
- func AssertCoherenceJobsInNamespace(ctx TestContext, t *testing.T, yamlFile, namespace string) (map[string]coh.CoherenceJob, []corev1.Pod)
- func AssertCoherenceJobsSpec(ctx TestContext, t *testing.T, jobs []coh.CoherenceJob) (map[string]coh.CoherenceJob, []corev1.Pod)
- func AssertCoherenceJobsSpecInNamespace(ctx TestContext, t *testing.T, jobs []coh.CoherenceJob, namespace string) (map[string]coh.CoherenceJob, []corev1.Pod)
- func AssertDeployments(ctx TestContext, t *testing.T, yamlFile string) (map[string]coh.Coherence, []corev1.Pod)
- func AssertDeploymentsInNamespace(ctx TestContext, t *testing.T, yamlFile, namespace string) (map[string]coh.Coherence, []corev1.Pod)
- func AssertSingleDeployment(ctx TestContext, t *testing.T, yamlFile string) (coh.Coherence, error)
- func CheckCanary(ctx TestContext, namespace, deploymentName string) error
- func CheckCanaryEventuallyGood(ctx TestContext, namespace, deploymentName string) error
- func ClearCanary(ctx TestContext, namespace, deploymentName string) error
- func DeleteJob(ctx TestContext, namespace, jobName string) error
- func DeletePersistentVolumes(ctx TestContext, namespace string)
- func DumpOperatorLog(ctx TestContext, namespace, directory string)
- func DumpOperatorLogs(t *testing.T, ctx TestContext)
- func DumpPodLog(ctx TestContext, pod *corev1.Pod, directory string)
- func DumpPodsForTest(ctx TestContext, t *testing.T)
- func DumpState(ctx TestContext, namespace, dir string)
- func EnsureLogsDir(subDir string) (string, error)
- func EnsureTestEnvVars()
- func FindActualFile(file string) (string, error)
- func FindK8sApiToolsDir() (string, error)
- func FindOperatorHelmChartDir() (string, error)
- func FindOperatorTestHelmChartDir() (string, error)
- func FindProjectRootDir() (string, error)
- func FindRuntimeCrdDir() (string, error)
- func FindTestCertsDir() (string, error)
- func FindTestLogsDir() (string, error)
- func FindToolsDir() (string, error)
- func GetBuildOutputDirectory() (os.FileInfo, error)
- func GetClientImage() string
- func GetCoherence(ctx TestContext, namespace, name string) (*coh.Coherence, error)
- func GetCoherenceCompatibilityImage() string
- func GetCoherenceJob(ctx TestContext, namespace, name string) (*coh.CoherenceJob, error)
- func GetDefaultCoherenceImage() string
- func GetDefaultCoherenceImageName() string
- func GetDefaultCoherenceImageRegistry() string
- func GetDefaultCoherenceImageTag() string
- func GetFirstPodReadyTime(pods []corev1.Pod, deployment string) metav1.Time
- func GetFirstPodScheduledTime(pods []corev1.Pod, deployment string) metav1.Time
- func GetImagePullSecrets() []coh.LocalObjectReference
- func GetKubeconfigAndNamespace(configPath string) (*rest.Config, string, error)
- func GetLastPodReadyTime(pods []corev1.Pod, deployment string) metav1.Time
- func GetOperatorImage() string
- func GetOperatorImageName() string
- func GetOperatorImageRegistry() string
- func GetOperatorVersionEnvVar() string
- func GetPrometheusNamespace() string
- func GetTestClientNamespace() string
- func GetTestClusterNamespace() string
- func GetTestNamespace() string
- func GetTestSSLSecretName() string
- func IsCoherenceVersionAtLeast(version ...int) (bool, error)
- func ListCoherencePods(ctx TestContext, namespace string) ([]corev1.Pod, error)
- func ListCoherencePodsForCluster(ctx TestContext, namespace, cluster string) ([]corev1.Pod, error)
- func ListCoherencePodsForDeployment(ctx TestContext, namespace, deployment string) ([]corev1.Pod, error)
- func ListJobsWithLabelSelector(ctx TestContext, namespace, selector string) ([]batchv1.Job, error)
- func ListOperatorPods(ctx TestContext, namespace string) ([]corev1.Pod, error)
- func ListPodsForStatefulSet(ctx TestContext, sts *appsv1.StatefulSet) (corev1.PodList, error)
- func ListPodsWithLabelAndFieldSelector(ctx TestContext, namespace, labelSelector, fieldSelector string) ([]corev1.Pod, error)
- func ListPodsWithLabelSelector(ctx TestContext, namespace, selector string) ([]corev1.Pod, error)
- func LoadFromYamlFile(file string, o interface{}) error
- func NewCoherenceFromYaml(namespace, file string) ([]coh.Coherence, error)
- func NewCoherenceFromYamlWithSuffix(namespace, file, suffix string) ([]coh.Coherence, error)
- func NewCoherenceJobFromYaml(namespace string, file string) ([]coh.CoherenceJob, error)
- func NewSingleCoherenceFromYaml(namespace, file string) (coh.Coherence, error)
- func NewSingleCoherenceFromYamlWithSuffix(namespace, file, suffix string) (coh.Coherence, error)
- func NewSingleCoherenceJobFromYaml(namespace, file string) (coh.CoherenceJob, error)
- func ObjectKey(obj runtime.Object) client.ObjectKey
- func Shutdown(pod *v1.Pod) error
- func ShutdownWithExitCode(pod *v1.Pod, exitCode int) error
- func SkipIfCoherenceVersionLessThan(t *testing.T, version ...int)
- func StartCanary(ctx TestContext, namespace, deploymentName string) error
- func WaitForCoherence(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) (*coh.Coherence, error)
- func WaitForCoherenceCleanup(ctx TestContext, namespace string) error
- func WaitForCoherenceCondition(testCtx TestContext, namespace, name string, ...) (*coh.Coherence, error)
- func WaitForCoherenceJobCondition(ctx TestContext, namespace, name string, condition DeploymentStateCondition, ...) (*coh.CoherenceJob, error)
- func WaitForDelete(ctx TestContext, obj client.Object) error
- func WaitForDeleteOfPodsWithSelector(ctx TestContext, namespace, selector string, ...) error
- func WaitForDeletion(ctx TestContext, namespace, name string, resource client.Object, ...) error
- func WaitForDeploymentReady(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) (*coh.Coherence, error)
- func WaitForEndpoints(ctx TestContext, namespace, service string, ...) (*corev1.Endpoints, error)
- func WaitForJob(ctx TestContext, namespace, stsName string, replicas int32, ...) (*batchv1.Job, error)
- func WaitForJobCompletion(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) error
- func WaitForJobsWithLabel(ctx TestContext, namespace, selector string, count int, ...) ([]batchv1.Job, error)
- func WaitForOperatorCleanup(ctx TestContext, namespace string) error
- func WaitForOperatorDeletion(ctx TestContext, namespace string, retryInterval, timeout time.Duration) error
- func WaitForOperatorPods(ctx TestContext, namespace string, retryInterval, timeout time.Duration) ([]corev1.Pod, error)
- func WaitForPodReady(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) error
- func WaitForPodsWithLabel(ctx TestContext, namespace, selector string, count int, ...) ([]corev1.Pod, error)
- func WaitForPodsWithLabelAndField(ctx TestContext, namespace, labelSelector, fieldSelector string, count int, ...) ([]corev1.Pod, error)
- func WaitForPodsWithSelector(ctx TestContext, namespace, selector string, ...) ([]corev1.Pod, error)
- func WaitForPodsWithSelectorAndReplicas(ctx TestContext, namespace, selector string, replicas int, ...) ([]corev1.Pod, error)
- func WaitForStatefulSet(ctx TestContext, namespace, stsName string, replicas int32, ...) (*appsv1.StatefulSet, error)
- func WaitForStatefulSetForDeployment(ctx TestContext, namespace string, deployment *coh.Coherence, ...) (*appsv1.StatefulSet, error)
- func WaitForStatefulSetPodCondition(ctx TestContext, namespace, stsName string, replicas int32, ...) (*appsv1.StatefulSet, error)
- type AvailablePorts
- type CoherenceLoader
- type DeploymentStateCondition
- func JobCompletedCondition(count int32) DeploymentStateCondition
- func JobFailedCondition(count int32) DeploymentStateCondition
- func JobSucceededCondition(count int32) DeploymentStateCondition
- func ReplicaCountCondition(replicas int32) DeploymentStateCondition
- func StatusPhaseCondition(phase coh.ConditionType) DeploymentStateCondition
- type OperatorSSL
- type OperatorSpec
- type OperatorValues
- type PortForwarder
- type TestContext
- func (in *TestContext) Cleanup()
- func (in *TestContext) CleanupAfterTest(t *testing.T)
- func (in *TestContext) CleanupNamespace(ns string)
- func (in *TestContext) Close()
- func (in *TestContext) CreateNamespace(ns string) error
- func (in *TestContext) DeleteNamespace(ns string) error
- func (in *TestContext) Logf(format string, a ...interface{})
- func (in *TestContext) Start() error
Constants ¶
const ( // TestNamespaceEnv is environment variable holding the name of the test k8s namespace. TestNamespaceEnv = "OPERATOR_NAMESPACE" // TestClusterNamespaceEnv is environment variable holding the name of the coherence cluster test k8s namespace. TestClusterNamespaceEnv = "CLUSTER_NAMESPACE" // TestClientNamespaceEnv is environment variable holding the name of the client test k8s namespace. TestClientNamespaceEnv = "OPERATOR_NAMESPACE_CLIENT" // PrometheusNamespaceEnv is environment variable holding the name of the Prometheus k8s namespace. PrometheusNamespaceEnv = "PROMETHEUS_NAMESPACE" // OperatorImageRegistryEnv is environment variable holding the registry of the Operator image. OperatorImageRegistryEnv = "OPERATOR_IMAGE_REGISTRY" // OperatorImageNameEnv is environment variable holding the name part of the Operator image. OperatorImageNameEnv = "OPERATOR_IMAGE_NAME" // CoherenceImageRegistryEnv is environment variable holding the registry of the default Coherence image. CoherenceImageRegistryEnv = "COHERENCE_IMAGE_REGISTRY" // CoherenceImageNameEnv is environment variable holding the name part of the default Coherence image. CoherenceImageNameEnv = "COHERENCE_IMAGE_NAME" // CoherenceImageTagEnv is environment variable holding the tag part of the default Coherence image. CoherenceImageTagEnv = "COHERENCE_IMAGE_TAG" // OperatorImageEnv is environment variable holding the full name of the Operator image. OperatorImageEnv = "OPERATOR_IMAGE" // ClientImageEnv is environment variable holding the name of the client test image. ClientImageEnv = "TEST_APPLICATION_IMAGE_CLIENT" // CohCompatibilityImageEnv is environment variable holding the name of the compatibility test image. CohCompatibilityImageEnv = "TEST_COMPATIBILITY_IMAGE" // TestSslSecretEnv is environment variable holding the name of the SSL certs secret. TestSslSecretEnv = "TEST_SSL_SECRET" // ImagePullSecEnv is environment variable holding the name of the image pull secrets. ImagePullSecEnv = "IMAGE_PULL_SECRETS" // CoherenceVersionEnv is environment variable holding the Coherence version. CoherenceVersionEnv = "COHERENCE_VERSION" // BuildOutputEnv is environment variable holding the build output directory. BuildOutputEnv = "BUILD_OUTPUT" // VersionEnv is environment variable holding the version the Operator. VersionEnv = "VERSION" )
Variables ¶
var ( RetryInterval = time.Second * 5 Timeout = time.Minute * 3 )
Functions ¶
func AssertCoherenceJobs ¶
func AssertCoherenceJobs(ctx TestContext, t *testing.T, yamlFile string) (map[string]coh.CoherenceJob, []corev1.Pod)
AssertCoherenceJobs tests that one or more CoherenceJobs can be created using the specified yaml.
func AssertCoherenceJobsInNamespace ¶
func AssertCoherenceJobsInNamespace(ctx TestContext, t *testing.T, yamlFile, namespace string) (map[string]coh.CoherenceJob, []corev1.Pod)
AssertCoherenceJobsInNamespace tests that a CoherenceJob can be created using the specified yaml.
func AssertCoherenceJobsSpec ¶
func AssertCoherenceJobsSpec(ctx TestContext, t *testing.T, jobs []coh.CoherenceJob) (map[string]coh.CoherenceJob, []corev1.Pod)
AssertCoherenceJobsSpec tests that a CoherenceJob can be created.
func AssertCoherenceJobsSpecInNamespace ¶
func AssertCoherenceJobsSpecInNamespace(ctx TestContext, t *testing.T, jobs []coh.CoherenceJob, namespace string) (map[string]coh.CoherenceJob, []corev1.Pod)
AssertCoherenceJobsSpecInNamespace tests that a CoherenceJob can be created.
func AssertDeployments ¶
func AssertDeployments(ctx TestContext, t *testing.T, yamlFile string) (map[string]coh.Coherence, []corev1.Pod)
AssertDeployments tests that one or more clusters can be created using the specified yaml.
func AssertDeploymentsInNamespace ¶
func AssertDeploymentsInNamespace(ctx TestContext, t *testing.T, yamlFile, namespace string) (map[string]coh.Coherence, []corev1.Pod)
AssertDeploymentsInNamespace tests that a cluster can be created using the specified yaml.
func AssertSingleDeployment ¶
AssertSingleDeployment tests that a cluster can be created using the specified yaml.
func CheckCanary ¶
func CheckCanary(ctx TestContext, namespace, deploymentName string) error
CheckCanary invokes the canary test in the deployment..
func CheckCanaryEventuallyGood ¶
func CheckCanaryEventuallyGood(ctx TestContext, namespace, deploymentName string) error
CheckCanaryEventuallyGood invokes the canary test in the deployment in a loop to ensure it is eventually ok.
func ClearCanary ¶
func ClearCanary(ctx TestContext, namespace, deploymentName string) error
ClearCanary clears the canary test in the deployment.
func DeleteJob ¶
func DeleteJob(ctx TestContext, namespace, jobName string) error
func DeletePersistentVolumes ¶
func DeletePersistentVolumes(ctx TestContext, namespace string)
func DumpOperatorLog ¶
func DumpOperatorLog(ctx TestContext, namespace, directory string)
DumpOperatorLog dumps the Operator Pod log to a file.
func DumpOperatorLogs ¶
func DumpOperatorLogs(t *testing.T, ctx TestContext)
DumpOperatorLogs dumps the operator logs
func DumpPodLog ¶
func DumpPodLog(ctx TestContext, pod *corev1.Pod, directory string)
DumpPodLog dumps the Pod log to a file.
func DumpPodsForTest ¶
func DumpPodsForTest(ctx TestContext, t *testing.T)
func DumpState ¶
func DumpState(ctx TestContext, namespace, dir string)
func EnsureLogsDir ¶
func EnsureTestEnvVars ¶
func EnsureTestEnvVars()
func FindActualFile ¶
func FindK8sApiToolsDir ¶
FindK8sApiToolsDir returns the k8s API build tools directory.
func FindOperatorHelmChartDir ¶
FindOperatorHelmChartDir returns the Operator Helm chart directory.
func FindOperatorTestHelmChartDir ¶
FindOperatorTestHelmChartDir returns the Operator test Helm chart directory where previous version charts are downloaded to.
func FindProjectRootDir ¶
FindProjectRootDir returns the project root directory.
func FindRuntimeCrdDir ¶
FindRuntimeCrdDir returns the CRD directory under the runtime assets.
func FindTestCertsDir ¶
FindTestCertsDir returns the test cert directory.
func FindTestLogsDir ¶
FindTestLogsDir returns the test log directory.
func FindToolsDir ¶
FindToolsDir returns the build tools directory.
func GetBuildOutputDirectory ¶
GetBuildOutputDirectory returns the build output directory
func GetClientImage ¶
func GetClientImage() string
GetClientImage returns the name of the client test image
func GetCoherence ¶
func GetCoherence(ctx TestContext, namespace, name string) (*coh.Coherence, error)
GetCoherence gets the specified Coherence resource
func GetCoherenceCompatibilityImage ¶
func GetCoherenceCompatibilityImage() string
GetCoherenceCompatibilityImage returns the name of the compatibility test image.
func GetCoherenceJob ¶
func GetCoherenceJob(ctx TestContext, namespace, name string) (*coh.CoherenceJob, error)
GetCoherenceJob gets the specified CoherenceJob resource
func GetDefaultCoherenceImage ¶
func GetDefaultCoherenceImage() string
GetDefaultCoherenceImage returns the full name of the default Coherence image.
func GetDefaultCoherenceImageName ¶
func GetDefaultCoherenceImageName() string
GetDefaultCoherenceImageName returns the name part of the default Coherence image.
func GetDefaultCoherenceImageRegistry ¶
func GetDefaultCoherenceImageRegistry() string
GetDefaultCoherenceImageRegistry returns the registry name of the default Coherence image.
func GetDefaultCoherenceImageTag ¶
func GetDefaultCoherenceImageTag() string
GetDefaultCoherenceImageTag returns the tag part of the default Coherence image.
func GetFirstPodReadyTime ¶
GetFirstPodReadyTime returns the first ready time from all the specified Pods for a given deployment
func GetFirstPodScheduledTime ¶
GetFirstPodScheduledTime returns the earliest scheduled time from all the specified Pods for a given deployment
func GetImagePullSecrets ¶
func GetImagePullSecrets() []coh.LocalObjectReference
GetImagePullSecrets returns the names of the image pull secrets.
func GetKubeconfigAndNamespace ¶
GetKubeconfigAndNamespace returns the *rest.Config and default namespace defined in the kubeconfig at the specified path. If no path is provided, returns the default *rest.Config and namespace
func GetLastPodReadyTime ¶
GetLastPodReadyTime returns the latest ready time from all the specified Pods for a given deployment
func GetOperatorImage ¶
func GetOperatorImage() string
GetOperatorImage returns the full name of the Operator image.
func GetOperatorImageName ¶
func GetOperatorImageName() string
GetOperatorImageName returns the name part of the Operator image.
func GetOperatorImageRegistry ¶
func GetOperatorImageRegistry() string
GetOperatorImageRegistry returns the registry name of the Operator image.
func GetOperatorVersionEnvVar ¶
func GetOperatorVersionEnvVar() string
GetOperatorVersionEnvVar returns the Operator version.
func GetPrometheusNamespace ¶
func GetPrometheusNamespace() string
GetPrometheusNamespace returns the name of the Prometheus namespace.
func GetTestClientNamespace ¶
func GetTestClientNamespace() string
GetTestClientNamespace returns the name of the client test namespace.
func GetTestClusterNamespace ¶
func GetTestClusterNamespace() string
GetTestClusterNamespace returns the name of the test cluster namespace.
func GetTestNamespace ¶
func GetTestNamespace() string
GetTestNamespace returns the name of the test namespace.
func GetTestSSLSecretName ¶
func GetTestSSLSecretName() string
GetTestSSLSecretName returns the name of the SSL cert secret.
func IsCoherenceVersionAtLeast ¶
IsCoherenceVersionAtLeast determines whether current Coherence version set in the COHERENCE_VERSION environment variable is greater than the specified version or the COHERENCE_VERSION environment variable has not been set.
func ListCoherencePods ¶
func ListCoherencePods(ctx TestContext, namespace string) ([]corev1.Pod, error)
ListCoherencePods lists the all Coherence deployment Pods in a namespace
func ListCoherencePodsForCluster ¶
func ListCoherencePodsForCluster(ctx TestContext, namespace, cluster string) ([]corev1.Pod, error)
ListCoherencePodsForCluster lists the Coherence Cluster Pods that exist for a cluster - this is Pods with the label "coherenceCluster=<cluster>"
func ListCoherencePodsForDeployment ¶
func ListCoherencePodsForDeployment(ctx TestContext, namespace, deployment string) ([]corev1.Pod, error)
ListCoherencePodsForDeployment lists the Pods that exist for a deployment - this is Pods with the label "coherenceDeployment=<deployment>"
func ListJobsWithLabelSelector ¶
func ListJobsWithLabelSelector(ctx TestContext, namespace, selector string) ([]batchv1.Job, error)
ListJobsWithLabelSelector lists the Coherence Cluster Jobs that exist for a given label selector.
func ListOperatorPods ¶
func ListOperatorPods(ctx TestContext, namespace string) ([]corev1.Pod, error)
ListOperatorPods lists the Operator Pods that exist - this is Pods with the label "name=coh-operator"
func ListPodsForStatefulSet ¶
func ListPodsForStatefulSet(ctx TestContext, sts *appsv1.StatefulSet) (corev1.PodList, error)
func ListPodsWithLabelAndFieldSelector ¶
func ListPodsWithLabelAndFieldSelector(ctx TestContext, namespace, labelSelector, fieldSelector string) ([]corev1.Pod, error)
ListPodsWithLabelAndFieldSelector lists the Coherence Cluster Pods that exist for a given label and field selectors.
func ListPodsWithLabelSelector ¶
func ListPodsWithLabelSelector(ctx TestContext, namespace, selector string) ([]corev1.Pod, error)
ListPodsWithLabelSelector lists the Coherence Cluster Pods that exist for a given label selector.
func LoadFromYamlFile ¶
LoadFromYamlFile loads the specified value from the yaml file.
func NewCoherenceFromYaml ¶
NewCoherenceFromYaml creates a new Coherence resource from a yaml file.
func NewCoherenceFromYamlWithSuffix ¶
NewCoherenceFromYamlWithSuffix creates a new Coherence resource from a yaml file. and adds a specified suffix to the Coherence resource names
func NewCoherenceJobFromYaml ¶
func NewCoherenceJobFromYaml(namespace string, file string) ([]coh.CoherenceJob, error)
NewCoherenceJobFromYaml creates a new CoherenceJob resource from a yaml file.
func NewSingleCoherenceFromYaml ¶
NewSingleCoherenceFromYaml creates a single new Coherence resource from a yaml file.
func NewSingleCoherenceFromYamlWithSuffix ¶
NewSingleCoherenceFromYamlWithSuffix creates a single new Coherence resource from a yaml file and adds a specified suffix to the Coherence resource names.
func NewSingleCoherenceJobFromYaml ¶
func NewSingleCoherenceJobFromYaml(namespace, file string) (coh.CoherenceJob, error)
NewSingleCoherenceJobFromYaml creates a single new CoherenceJob resource from a yaml file.
func ShutdownWithExitCode ¶
ShutdownWithExitCode stops the test Pod with the specified exit code.
func SkipIfCoherenceVersionLessThan ¶
SkipIfCoherenceVersionLessThan skips the specified test if the current Coherence version set in the COHERENCE_VERSION environment variable is less than the specified version.
func StartCanary ¶
func StartCanary(ctx TestContext, namespace, deploymentName string) error
StartCanary initialises the canary test in the deployment being scaled.
func WaitForCoherence ¶
func WaitForCoherence(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) (*coh.Coherence, error)
WaitForCoherence waits for a Coherence resource to be created.
func WaitForCoherenceCleanup ¶
func WaitForCoherenceCleanup(ctx TestContext, namespace string) error
WaitForCoherenceCleanup waits until there are no Coherence resources left in the test namespace. The default clean-up hooks only wait for deletion of resources directly created via the test client
func WaitForCoherenceCondition ¶
func WaitForCoherenceCondition(testCtx TestContext, namespace, name string, condition DeploymentStateCondition, retryInterval, timeout time.Duration) (*coh.Coherence, error)
WaitForCoherenceCondition waits for a Coherence resource to be created.
func WaitForCoherenceJobCondition ¶
func WaitForCoherenceJobCondition(ctx TestContext, namespace, name string, condition DeploymentStateCondition, retryInterval, timeout time.Duration) (*coh.CoherenceJob, error)
func WaitForDelete ¶
func WaitForDelete(ctx TestContext, obj client.Object) error
WaitForDelete waits for the provided runtime object to be deleted from cluster
func WaitForDeleteOfPodsWithSelector ¶
func WaitForDeleteOfPodsWithSelector(ctx TestContext, namespace, selector string, retryInterval, timeout time.Duration) error
WaitForDeleteOfPodsWithSelector waits for Pods to be deleted.
func WaitForDeletion ¶
func WaitForDeletion(ctx TestContext, namespace, name string, resource client.Object, retryInterval, timeout time.Duration) error
WaitForDeletion waits for deletion of the specified resource.
func WaitForDeploymentReady ¶
func WaitForDeploymentReady(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) (*coh.Coherence, error)
WaitForDeploymentReady waits for a Coherence deployment to be ready.
func WaitForEndpoints ¶
func WaitForEndpoints(ctx TestContext, namespace, service string, retryInterval, timeout time.Duration) (*corev1.Endpoints, error)
WaitForEndpoints waits for Enpoints for a Service to be created.
func WaitForJob ¶
func WaitForJob(ctx TestContext, namespace, stsName string, replicas int32, retryInterval, timeout time.Duration) (*batchv1.Job, error)
WaitForJob waits for a Job to be created with the specified number of replicas.
func WaitForJobCompletion ¶
func WaitForJobCompletion(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) error
WaitForJobCompletion waits for a specified k8s Job to complete.
func WaitForJobsWithLabel ¶
func WaitForJobsWithLabel(ctx TestContext, namespace, selector string, count int, retryInterval, timeout time.Duration) ([]batchv1.Job, error)
WaitForJobsWithLabel waits for at least the required number of Jobs matching the specified labels selector to be created.
func WaitForOperatorCleanup ¶
func WaitForOperatorCleanup(ctx TestContext, namespace string) error
WaitForOperatorCleanup waits until there are no Operator Pods in the test namespace.
func WaitForOperatorDeletion ¶
func WaitForOperatorDeletion(ctx TestContext, namespace string, retryInterval, timeout time.Duration) error
WaitForOperatorDeletion waits for deletion of the Operator Pods.
func WaitForOperatorPods ¶
func WaitForOperatorPods(ctx TestContext, namespace string, retryInterval, timeout time.Duration) ([]corev1.Pod, error)
WaitForOperatorPods waits for a Coherence Operator Pods to be created.
func WaitForPodReady ¶
func WaitForPodReady(ctx TestContext, namespace, name string, retryInterval, timeout time.Duration) error
WaitForPodReady waits for a Pods to be ready.
func WaitForPodsWithLabel ¶
func WaitForPodsWithLabel(ctx TestContext, namespace, selector string, count int, retryInterval, timeout time.Duration) ([]corev1.Pod, error)
WaitForPodsWithLabel waits for at least the required number of Pods matching the specified labels selector to be created.
func WaitForPodsWithLabelAndField ¶
func WaitForPodsWithLabelAndField(ctx TestContext, namespace, labelSelector, fieldSelector string, count int, retryInterval, timeout time.Duration) ([]corev1.Pod, error)
WaitForPodsWithLabelAndField waits for at least the required number of pending Pods
func WaitForPodsWithSelector ¶
func WaitForPodsWithSelector(ctx TestContext, namespace, selector string, retryInterval, timeout time.Duration) ([]corev1.Pod, error)
WaitForPodsWithSelector waits for a Coherence Operator Pods to be created.
func WaitForPodsWithSelectorAndReplicas ¶
func WaitForPodsWithSelectorAndReplicas(ctx TestContext, namespace, selector string, replicas int, retryInterval, timeout time.Duration) ([]corev1.Pod, error)
WaitForPodsWithSelectorAndReplicas waits for Pods to be created.
func WaitForStatefulSet ¶
func WaitForStatefulSet(ctx TestContext, namespace, stsName string, replicas int32, retryInterval, timeout time.Duration) (*appsv1.StatefulSet, error)
WaitForStatefulSet waits for a StatefulSet to be created with the specified number of replicas.
func WaitForStatefulSetForDeployment ¶
func WaitForStatefulSetForDeployment(ctx TestContext, namespace string, deployment *coh.Coherence, retryInterval, timeout time.Duration) (*appsv1.StatefulSet, error)
WaitForStatefulSetForDeployment waits for a StatefulSet to be created for the specified deployment.
func WaitForStatefulSetPodCondition ¶
func WaitForStatefulSetPodCondition(ctx TestContext, namespace, stsName string, replicas int32, c corev1.PodConditionType, retryInterval, timeout time.Duration) (*appsv1.StatefulSet, error)
WaitForStatefulSetPodCondition waits for all Pods in a StatefulSet to have the specified condition.
Types ¶
type AvailablePorts ¶
type AvailablePorts interface { Next() (int32, error) NextPortForward(ports ...int32) ([]string, error) }
AvailablePorts finds free ports on the current machine.
func GetAvailablePorts ¶
func GetAvailablePorts() AvailablePorts
GetAvailablePorts obtains an AvailablePorts that finds free ephemeral ports.
type CoherenceLoader ¶
type CoherenceLoader struct { }
CoherenceLoader can load Coherence resources from yaml files.
func (*CoherenceLoader) LoadYamlIntoTemplate ¶
func (in *CoherenceLoader) LoadYamlIntoTemplate(template interface{}, file string) error
type DeploymentStateCondition ¶
type DeploymentStateCondition interface { Test(coh.CoherenceResource) bool String() string }
DeploymentStateCondition is a function that takes a deployment and determines whether it meets a condition
func JobCompletedCondition ¶
func JobCompletedCondition(count int32) DeploymentStateCondition
func JobFailedCondition ¶
func JobFailedCondition(count int32) DeploymentStateCondition
func JobSucceededCondition ¶
func JobSucceededCondition(count int32) DeploymentStateCondition
func ReplicaCountCondition ¶
func ReplicaCountCondition(replicas int32) DeploymentStateCondition
func StatusPhaseCondition ¶
func StatusPhaseCondition(phase coh.ConditionType) DeploymentStateCondition
type OperatorSSL ¶
type OperatorSSL struct { Secrets *string `json:"secrets,omitempty"` KeyFile *string `json:"keyFile,omitempty"` CertFile *string `json:"certFile,omitempty"` CaFile *string `json:"caFile,omitempty"` }
OperatorSSL defines the SSL settings for the Operator.
func CreateSslSecret ¶
func CreateSslSecret(kubeClient kubernetes.Interface, namespace, name string) (*OperatorSSL, *coh.SSLSpec, error)
CreateSslSecret creates a k8s secret that can be used for SSL testing.
func GetTestSslSecret ¶
func GetTestSslSecret() (*OperatorSSL, *coh.SSLSpec, error)
GetTestSslSecret gets the test k8s secret that can be used for SSL testing.
type OperatorSpec ¶
type OperatorSpec struct { Image *string `json:"image,omitempty"` ImagePullPolicy *coreV1.PullPolicy `json:"imagePullPolicy,omitempty"` SSL *OperatorSSL `json:"ssl,omitempty"` }
OperatorSpec defines the settings for the Operator.
type OperatorValues ¶
type OperatorValues struct { Replicas int `json:"replicas,omitempty"` // The name to use for the service account to use when RBAC is enabled // The role bindings must already have been created as this chart does not create them it just // sets the serviceAccountName value in the Pod spec. // +optional ServiceAccountName string `json:"serviceAccountName,omitempty"` // The secrets to be used when pulling images. Secrets must be manually created in the target namespace. // ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ // +optional ImagePullSecrets []coh.LocalObjectReference `json:"imagePullSecrets,omitempty"` // Affinity controls Pod scheduling preferences. // ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity // +optional Affinity *coreV1.Affinity `json:"affinity,omitempty"` // NodeSelector is the Node labels for pod assignment // ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector // +optional NodeSelector *coreV1.NodeSelector `json:"nodeSelector,omitempty"` // If specified, the pod's tolerations. // +optional Tolerations *[]coreV1.Toleration `json:"tolerations,omitempty"` // CoherenceOperator groups the values used to configure the operator // +optional CoherenceOperator *OperatorSpec `json:"coherenceOperator,omitempty"` // Specifies whether to generate the ClusterRole yaml. // +optional EnableClusterRole *bool `json:"enableClusterRole,omitempty"` // The Helm full name override // +optional FullnameOverride *string `json:"fullnameOverride,omitempty"` }
func (*OperatorValues) GetReplicas ¶
func (v *OperatorValues) GetReplicas(dflt int) int
GetReplicas retruns the replica count in the values file, or the dflt value if no value is set in the values file.
func (*OperatorValues) LoadFromYaml ¶
func (v *OperatorValues) LoadFromYaml(file string) error
LoadFromYaml loads the data from the specified YAML file into this OperatorValues
func (*OperatorValues) SetEnableClusterRole ¶
func (v *OperatorValues) SetEnableClusterRole(enabled bool)
SetEnableClusterRole sets whether to generate the ClusterRole yaml.
func (*OperatorValues) ToMap ¶
func (v *OperatorValues) ToMap(m *map[string]interface{}) error
ToMap marshals this OperatorValues to yaml
func (*OperatorValues) ToYaml ¶
func (v *OperatorValues) ToYaml() ([]byte, error)
ToYaml marshals this OperatorValues to yaml
type PortForwarder ¶
type PortForwarder struct { // The optional Pod namespace. If not set the default namespace is used. Namespace string // The name of the Pod to forward ports to. PodName string // The ports to forward. Each string in the slice is the same format that // ports are specified in the kubectl port-forward command. Ports []string // A flag indicating whether this PortForwarder is running Running bool KubeClient kubernetes.Interface // contains filtered or unexported fields }
PortForwarder forwards ports from the local machine to a K8s Pod. This works in the same way the kubectl port-forward works.
Typical usage would be to create the PortForwarder, start it, check for error and defer the close. For example
f := helper.PortForwarder{Namespace:"my-test-ns", PodName:"my-pod", Ports:[]string{"30000:30000"}} err := f.Start() if err != nil { ... handle error ... } defer f.Close() ... now the ports are being forwarded ...
func PortForwarderForPod ¶
PortForwarderForPod forwards all ports in a Pod to local ports. This method returns a PortForwarder that is not started, a map of port name to local port and any error that may have occurred.
func StartPortForwarderForPod ¶
StartPortForwarderForPod forwards all ports in a Pod to local ports. This method returns a running PortForwarder, a map of port name to local port and any error that may have occurred.
type TestContext ¶
type TestContext struct { Config *rest.Config Client client.Client KubeClient kubernetes.Interface Manager ctrl.Manager Logger logr.Logger Context context.Context Cancel context.CancelFunc RestServer oprest.Server RestEndpoints map[string]func(w http.ResponseWriter, r *http.Request) // contains filtered or unexported fields }
TestContext is a context for end-to-end tests
func NewContext ¶
func NewContext(startController bool, watchNamespaces ...string) (TestContext, error)
NewContext creates a new TestContext.
func NewStartedContext ¶
func NewStartedContext(startController bool, watchNamespaces ...string) (TestContext, error)
NewStartedContext creates a new TestContext starts it.
func (*TestContext) Cleanup ¶
func (in *TestContext) Cleanup()
func (*TestContext) CleanupAfterTest ¶
func (in *TestContext) CleanupAfterTest(t *testing.T)
func (*TestContext) CleanupNamespace ¶
func (in *TestContext) CleanupNamespace(ns string)
func (*TestContext) Close ¶
func (in *TestContext) Close()
func (*TestContext) CreateNamespace ¶
func (in *TestContext) CreateNamespace(ns string) error
func (*TestContext) DeleteNamespace ¶
func (in *TestContext) DeleteNamespace(ns string) error
func (*TestContext) Logf ¶
func (in *TestContext) Logf(format string, a ...interface{})
func (*TestContext) Start ¶
func (in *TestContext) Start() error