framework

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TokenRequest represents the "TokenRequest" feature.
	TokenRequest = ClusterFeature("TokenRequest")

	// ShareProcessNamespace represents the "ShareProcessNamespace" feature.
	ShareProcessNamespace = ClusterFeature("ShareProcessNamespace")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterFeature added in v0.4.2

type ClusterFeature string

ClusterFeature represents a feature that can be enabled or disabled on the target Kubernetes cluster.

type Framework

type Framework struct {
	// ClusterFeatures is a map indicating whether specific
	// cluster features have been detected in the target cluster.
	ClusterFeatures map[ClusterFeature]bool

	// FeatureMap is the map containing features and their status for the current instance of the end-to-end test suite.
	FeatureMap features.FeatureMap

	// KubeClient is an interface to the Kubernetes base APIs.
	KubeClient kubernetes.Interface

	// Namespace is the namespace in which we are running.
	Namespace string

	// NatsClient is an interface to the nats.io/v1alpha2 API.
	NatsClient natsclient.Interface
}

Framework encapsulates the configuration for the current run, and provides helper methods to be used during testing.

func New added in v0.4.2

func New(featureMap features.FeatureMap, kubeconfig, namespace string) *Framework

New returns a new instance of the testing framework.

func (*Framework) Cleanup added in v0.4.2

func (f *Framework) Cleanup()

Cleanup deletes the nats-operator deployment and the nats-operator-e2e pod, ignoring errors.

func (*Framework) ConnectToNatsClusterWithNatsServiceRole added in v0.4.2

func (f *Framework) ConnectToNatsClusterWithNatsServiceRole(natsCluster *natsv1alpha2.NatsCluster, nsr *natsv1alpha2.NatsServiceRole) (*nats.Conn, error)

ConnectToNatsClusterWithNatsServiceRole attempts to connect to the specified NATS cluster using the specified NatsServiceRole. It returns the NATS connection back to the caller, or an error. It is the caller's responsibility to close the connection when it is no longer needed.

func (*Framework) ConnectToNatsClusterWithUsernamePassword added in v0.4.2

func (f *Framework) ConnectToNatsClusterWithUsernamePassword(natsCluster *natsv1alpha2.NatsCluster, username, password string) (*nats.Conn, error)

ConnectToNatsClusterWithUsernamePassword attempts to connect to the specified NATS cluster using the username and password. It returns the NATS connection back to the caller, or an error. It is the caller's responsibility to close the connection when it is no longer needed.

func (*Framework) CreateCluster added in v0.4.2

func (f *Framework) CreateCluster(namespace, prefix string, size int, version string, fn ...NatsClusterCustomizer) (*natsv1alpha2.NatsCluster, error)

CreateCluster creates a NatsCluster resource which name starts with the specified prefix, and using the specified size and version.

Before actually creating the NatsCluster resource, it allows for the resource to be customized via the application of NatsClusterCustomizer functions.

func (*Framework) CreateNamespace added in v0.4.2

func (f *Framework) CreateNamespace() (*corev1.Namespace, error)

CreateNamespace creates a namespace with a random name.

func (*Framework) CreateNatsServiceRole added in v0.4.2

func (f *Framework) CreateNatsServiceRole(namespace, prefix string, fn ...NatsServiceRoleCustomizer) (*natsv1alpha2.NatsServiceRole, error)

CreateNatsServiceRole creates a NatsServiceRole resource which name starts with the specified prefix. Before actually creating the CreateNatsServiceRole resource, it allows for the resource to be customized via the application of NatsServiceRoleCustomizer functions.

func (*Framework) CreateSecret added in v0.4.2

func (f *Framework) CreateSecret(namespace string, key string, val []byte) (*v1.Secret, error)

CreateSecret creates a Secret resource containing the specified key and value.

func (*Framework) DeleteCluster added in v0.4.2

func (f *Framework) DeleteCluster(natsCluster *natsv1alpha2.NatsCluster) error

DeleteCluster deletes the specified NatsCluster resource.

func (*Framework) DeleteNamespace added in v0.4.2

func (f *Framework) DeleteNamespace(namespace *corev1.Namespace) error

DeleteNamespace deletes the specified namespace.

func (*Framework) DeleteNatsServiceRole added in v0.4.2

func (f *Framework) DeleteNatsServiceRole(nsr *natsv1alpha2.NatsServiceRole) error

DeleteNatsServiceRole deletes the specified NatsServiceRole resource.

func (*Framework) DeleteSecret added in v0.4.2

func (f *Framework) DeleteSecret(secret *v1.Secret) error

DeleteSecret deletes the specified Secret resource.

func (*Framework) FeatureDetect added in v0.4.2

func (f *Framework) FeatureDetect()

FeatureDetect performs feature detection on the target Kubernetes cluster.

func (*Framework) NatsClusterHasExpectedRouteCount added in v0.4.2

func (f *Framework) NatsClusterHasExpectedRouteCount(natsCluster *natsv1alpha2.NatsCluster, expectedSize int) (bool, error)

NatsClusterHasExpectedRouteCount returns whether every pod in the specified NatsCluster is reporting the expected number of routes.

func (*Framework) NatsClusterHasExpectedVersion added in v0.4.2

func (f *Framework) NatsClusterHasExpectedVersion(natsCluster *natsv1alpha2.NatsCluster, expectedVersion string) (bool, error)

NatsClusterHasExpectedVersion returns whether every pod in the specified NatsCluster is running the specified version of NATS.

func (*Framework) PatchCluster added in v0.4.2

func (f *Framework) PatchCluster(natsCluster *natsv1alpha2.NatsCluster) (*natsv1alpha2.NatsCluster, error)

PatchCluster performs a patch on the specified NatsCluster resource to align its ".spec" field with the provided value. It takes the desired state as an argument and patches the NatsCluster resource accordingly.

func (*Framework) PatchNatsServiceRole added in v0.4.2

func (f *Framework) PatchNatsServiceRole(nsr *natsv1alpha2.NatsServiceRole) (*natsv1alpha2.NatsServiceRole, error)

PatchNatsServiceRole performs a patch on the specified NatsServiceRole resource to align its ".spec" field with the provided value. It takes the desired state as an argument and patches the NatsServiceRole resource accordingly.

func (*Framework) PatchSecret added in v0.4.2

func (f *Framework) PatchSecret(secret *v1.Secret) (*v1.Secret, error)

PatchSecret performs a patch on the specified Secret resource to align its ".data" field with the provided value. It takes the desired state as an argument and patches the Secret resource accordingly.

func (*Framework) PodsForNatsCluster added in v0.4.2

func (f *Framework) PodsForNatsCluster(natsCluster *natsv1alpha2.NatsCluster) ([]v1.Pod, error)

PodsForNatsCluster returns a slice containing all pods that belong to the specified NatsCluster resource.

func (*Framework) Require added in v0.4.2

func (f *Framework) Require(t *testing.T, features ...ClusterFeature)

Require skips a test requiring features that are not enabled in the cluster.

func (*Framework) RouteCountForPod added in v0.4.2

func (f *Framework) RouteCountForPod(pod v1.Pod) (int, error)

RouteCountForPod returns the number of routes reported by the specified pod.

func (*Framework) SecretsForNatsCluster added in v0.4.4

func (f *Framework) SecretsForNatsCluster(natsCluster *natsv1alpha2.NatsCluster) ([]v1.Secret, error)

SecretsForNatsCluster returns a slice containing all pods that belong to the specified NatsCluster resource.

func (*Framework) ServicesForNatsCluster added in v0.4.4

func (f *Framework) ServicesForNatsCluster(natsCluster *natsv1alpha2.NatsCluster) ([]v1.Service, error)

ServicesForNatsCluster returns a slice containing all pods that belong to the specified NatsCluster resource.

func (*Framework) UpdateCluster added in v0.4.2

func (f *Framework) UpdateCluster(natsCluster *natsv1alpha2.NatsCluster) (*natsv1alpha2.NatsCluster, error)

UpdateCluster deletes the specified NatsCluster resource.

func (*Framework) VersionForPod added in v0.4.2

func (f *Framework) VersionForPod(pod v1.Pod) (string, error)

VersionForPod returns the version of NATS reported by the specified pod.

func (*Framework) WaitForNatsOperator added in v0.4.2

func (f *Framework) WaitForNatsOperator() error

WaitForNatsOperator waits for the nats-operator deployment to have at least one available replica.

func (*Framework) WaitForNatsOperatorE2ePodTermination added in v0.4.2

func (f *Framework) WaitForNatsOperatorE2ePodTermination() (int, error)

WaitForNatsOperatorE2ePodTermination waits for the nats-operator pod to be running and ready. It then starts streaming logs and returns the pod's exit code, or an error if any error was found during the process.

func (*Framework) WaitUntilExpectedRoutesInConfig added in v0.4.2

func (f *Framework) WaitUntilExpectedRoutesInConfig(ctx context.Context, natsCluster *natsv1alpha2.NatsCluster) error

WaitUntilExpectedRoutesInConfig waits until the expected routes for the specified NatsCluster are present in its configuration secret.

func (*Framework) WaitUntilFullMesh added in v0.4.2

func (f *Framework) WaitUntilFullMesh(ctx context.Context, natsCluster *natsv1alpha2.NatsCluster, expectedSize int) error

WaitUntilFullMesh waits until all the pods belonging to the specified NatsCluster report the expected number of routes. This function is a weaker variant of WaitUntilFullMeshWithVersion and should only be called in very specific use cases.

func (*Framework) WaitUntilFullMeshWithVersion added in v0.4.2

func (f *Framework) WaitUntilFullMeshWithVersion(ctx context.Context, natsCluster *natsv1alpha2.NatsCluster, expectedSize int, expectedVersion string) error

WaitUntilFullMeshWithVersion waits until all the pods belonging to the specified NatsCluster report the expected number of routes and the expected version.

func (*Framework) WaitUntilNatsClusterCondition added in v0.4.2

func (f *Framework) WaitUntilNatsClusterCondition(ctx context.Context, natsCluster *natsv1alpha2.NatsCluster, fn watch.ConditionFunc) error

WaitUntilNatsClusterCondition waits until the specified condition is verified in the specified NatsCluster.

func (*Framework) WaitUntilPodBootContainerLogLineMatches added in v0.5.0

func (f *Framework) WaitUntilPodBootContainerLogLineMatches(ctx context.Context, natsCluster *natsv1alpha2.NatsCluster, podIndex int, regex string) error

WaitUntilPodBootContainerLogLineMatches waits until a line in the logs for the pod with the specified index and belonging to the specified NatsCluster resource matches the provided regular expression.

func (*Framework) WaitUntilPodLogLineMatches added in v0.4.2

func (f *Framework) WaitUntilPodLogLineMatches(ctx context.Context, natsCluster *natsv1alpha2.NatsCluster, podIndex int, regex string) error

WaitUntilPodLogLineMatches waits until a line in the logs for the pod with the specified index and belonging to the specified NatsCluster resource matches the provided regular expression.

func (*Framework) WaitUntilSecretCondition added in v0.4.2

func (f *Framework) WaitUntilSecretCondition(ctx context.Context, natsCluster *natsv1alpha2.NatsCluster, fn watch.ConditionFunc) error

WaitUntilSecretCondition waits until the specified condition is verified in configuration secret for the specified NatsCluster resource.

type NatsClusterCustomizer added in v0.4.2

type NatsClusterCustomizer func(natsCluster *natsv1alpha2.NatsCluster)

NatsClusterCustomizer represents a function that allows for customizing a NatsCluster resource before it is created.

type NatsServiceRoleCustomizer added in v0.4.2

type NatsServiceRoleCustomizer func(natsServiceRole *natsv1alpha2.NatsServiceRole)

NatsServiceRoleCustomizer represents a function that allows for customizing a NatsServiceRole resource before it is created.

Jump to

Keyboard shortcuts

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