helper

package
v0.0.0-...-fc29aca Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: UPL-1.0 Imports: 57 Imported by: 0

Documentation

Overview

Package helper contains various helpers for use in end-to-end testing.

Index

Constants

View Source
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

View Source
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

func AssertSingleDeployment(ctx TestContext, t *testing.T, yamlFile string) (coh.Coherence, error)

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 EnsureLogsDir(subDir string) (string, error)

func EnsureTestEnvVars

func EnsureTestEnvVars()

func FindActualFile

func FindActualFile(file string) (string, error)

func FindOperatorHelmChartDir

func FindOperatorHelmChartDir() (string, error)

FindOperatorHelmChartDir returns the Operator Helm chart directory.

func FindOperatorTestHelmChartDir

func FindOperatorTestHelmChartDir() (string, error)

FindOperatorTestHelmChartDir returns the Operator test Helm chart directory where previous version charts are downloaded to.

func FindProjectRootDir

func FindProjectRootDir() (string, error)

FindProjectRootDir returns the project root directory.

func FindTestCertsDir

func FindTestCertsDir() (string, error)

FindTestCertsDir returns the test cert directory.

func FindTestLogsDir

func FindTestLogsDir() (string, error)

FindTestLogsDir returns the test log directory.

func GetBuildOutputDirectory

func GetBuildOutputDirectory() (os.FileInfo, error)

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

func GetFirstPodReadyTime(pods []corev1.Pod, deployment string) metav1.Time

GetFirstPodReadyTime returns the first ready time from all the specified Pods for a given deployment

func GetFirstPodScheduledTime

func GetFirstPodScheduledTime(pods []corev1.Pod, deployment string) metav1.Time

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

func GetKubeconfigAndNamespace(configPath string) (*rest.Config, string, error)

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

func GetLastPodReadyTime(pods []corev1.Pod, deployment string) metav1.Time

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

func IsCoherenceVersionAtLeast(version ...int) (bool, error)

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

func LoadFromYamlFile(file string, o interface{}) error

LoadFromYamlFile loads the specified value from the yaml file.

func NewCoherenceFromYaml

func NewCoherenceFromYaml(namespace, file string) ([]coh.Coherence, error)

NewCoherenceFromYaml creates a new Coherence resource from a yaml file.

func NewCoherenceFromYamlWithSuffix

func NewCoherenceFromYamlWithSuffix(namespace, file, suffix string) ([]coh.Coherence, error)

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

func NewSingleCoherenceFromYaml(namespace, file string) (coh.Coherence, error)

NewSingleCoherenceFromYaml creates a single new Coherence resource from a yaml file.

func NewSingleCoherenceFromYamlWithSuffix

func NewSingleCoherenceFromYamlWithSuffix(namespace, file, suffix string) (coh.Coherence, error)

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 ObjectKey

func ObjectKey(obj runtime.Object) client.ObjectKey

ObjectKey returns an instantiated ObjectKey for the provided object.

func Shutdown

func Shutdown(pod *v1.Pod) error

Shutdown stops the test Pod.

func ShutdownWithExitCode

func ShutdownWithExitCode(pod *v1.Pod, exitCode int) error

ShutdownWithExitCode stops the test Pod with the specified exit code.

func SkipIfCoherenceVersionLessThan

func SkipIfCoherenceVersionLessThan(t *testing.T, version ...int)

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.

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

func PortForwarderForPod(pod *corev1.Pod) (*PortForwarder, map[string]int32, error)

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

func StartPortForwarderForPod(pod *corev1.Pod) (*PortForwarder, map[string]int32, error)

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.

func (*PortForwarder) Close

func (f *PortForwarder) Close()

Close the PortForwarder.

func (*PortForwarder) Start

func (f *PortForwarder) Start() error

Start the PortForwarder.

type TestContext

type TestContext struct {
	Config     *rest.Config
	Client     client.Client
	KubeClient kubernetes.Interface
	Manager    ctrl.Manager
	Logger     logr.Logger
	Context    context.Context
	// 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 (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{})

Directories

Path Synopsis
matchers contains custom implementations of Gomega matchers.
matchers contains custom implementations of Gomega matchers.

Jump to

Keyboard shortcuts

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