framework

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 61 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinioNamespace = "minio"
)

Variables

View Source
var (
	Client client.Client
)

Functions

func CleanupForKubernetes

func CleanupForKubernetes(input string) string

func Init

func Init(t *testing.T)

Types

type ClusterKey

type ClusterKey struct {
	types.NamespacedName

	K8sContext string
}

func NewClusterKey added in v0.5.0

func NewClusterKey(context, namespace, name string) ClusterKey

func (ClusterKey) String

func (k ClusterKey) String() string

type E2eFramework

type E2eFramework struct {
	*Framework
	// contains filtered or unexported fields
}

func NewE2eFramework

func NewE2eFramework(t *testing.T, kubeconfigFile string, controlPlane string, dataPlanes ...string) (*E2eFramework, error)

func (*E2eFramework) CreateCassandraEncryptionStoresSecret

func (f *E2eFramework) CreateCassandraEncryptionStoresSecret(namespace string) error

func (*E2eFramework) CreateExternalDc added in v1.16.0

func (f *E2eFramework) CreateExternalDc(namespace string, seedIp string) error

func (*E2eFramework) CreateMedusaBucket added in v1.8.0

func (f *E2eFramework) CreateMedusaBucket(namespace string) error

func (*E2eFramework) CreateMedusaSecret added in v1.8.0

func (f *E2eFramework) CreateMedusaSecret(namespace string) error

func (*E2eFramework) DeleteDatacenters

func (f *E2eFramework) DeleteDatacenters(namespace string, timeout, interval time.Duration) error

DeleteDatacenters deletes all CassandraDatacenters in namespace in all remote clusters. This function blocks until all pods from all CassandraDatacenters have terminated.

func (*E2eFramework) DeleteK8ssandraOperatorPods

func (f *E2eFramework) DeleteK8ssandraOperatorPods(namespace string, timeout, interval time.Duration) error

func (*E2eFramework) DeleteNamespace

func (f *E2eFramework) DeleteNamespace(name string, timeout, interval time.Duration) error

DeleteNamespace Deletes the namespace from all remote clusters and blocks until they have completely terminated.

func (*E2eFramework) DeleteReapers

func (f *E2eFramework) DeleteReapers(namespace string, timeout, interval time.Duration) error

DeleteReapers deletes all Reapers in namespace in all remote clusters. This function blocks until all pods from all Reapers have terminated.

func (*E2eFramework) DeleteReplicatedSecrets

func (f *E2eFramework) DeleteReplicatedSecrets(namespace string, timeout, interval time.Duration) error

DeleteReplicatedSecrets deletes all the ReplicatedSecrets in the namespace. This causes some delay while secret controller removes the finalizers and clears the replicated secrets from remote clusters.

func (*E2eFramework) DeleteStargates

func (f *E2eFramework) DeleteStargates(namespace string, timeout, interval time.Duration) error

DeleteStargates deletes all Stargates in namespace in all remote clusters. This function blocks until all pods from all Stargates have terminated.

func (*E2eFramework) DeployCassandraConfigMap

func (f *E2eFramework) DeployCassandraConfigMap(namespace string) error

func (*E2eFramework) DeployFixture added in v1.1.0

func (f *E2eFramework) DeployFixture(namespace string, fixture *TestFixture, zones map[string]string, storage string, hostNetwork bool, medusaImageTag string) error

func (*E2eFramework) DeployGraphIngresses added in v1.3.0

func (f *E2eFramework) DeployGraphIngresses(t *testing.T, k8sContext, namespace, graphServiceName string, graphHostAndPort HostAndPort)

func (*E2eFramework) DeployK8sClientConfigs

func (f *E2eFramework) DeployK8sClientConfigs(namespace, srcKubeconfig, destKubeconfig, destContext string) error

func (*E2eFramework) DeployK8ssandraOperator

func (f *E2eFramework) DeployK8ssandraOperator(config OperatorDeploymentConfig) error

DeployK8ssandraOperator deploys k8ssandra-operator both in the control plane cluster and in the data plane cluster(s). Note that the control plane cluster can also be one of the data plane clusters. It then deploys the operator in the data plane clusters with the K8ssandraCluster controller disabled. When clusterScoped is true the operator is configured to watch all namespaces and is deployed in the k8ssandra-operator namespace.

func (*E2eFramework) DeployReaperIngresses

func (f *E2eFramework) DeployReaperIngresses(t *testing.T, k8sContext, namespace, reaperServiceName string, reaperHostAndPort HostAndPort)

func (*E2eFramework) DeploySolrIngresses added in v1.3.0

func (f *E2eFramework) DeploySolrIngresses(t *testing.T, k8sContext, namespace, solrServiceName string, solrHostAndPort HostAndPort)

func (*E2eFramework) DeployStargateIngresses

func (f *E2eFramework) DeployStargateIngresses(t *testing.T, k8sContext, namespace, stargateServiceName string, stargateRestHostAndPort, stargateGrpcHostAndPort HostAndPort)

func (*E2eFramework) DumpClusterInfo

func (f *E2eFramework) DumpClusterInfo(test string, namespaces ...string) error

DumpClusterInfo Executes `kubectl cluster-info dump -o yaml` on each cluster. The output is stored under <project-root>/build/test.

func (*E2eFramework) ExecuteCql

func (f *E2eFramework) ExecuteCql(ctx context.Context, k8sContext, namespace, clusterName, pod, query string) (string, error)

func (*E2eFramework) ExecuteCqlNoAuth added in v1.4.0

func (f *E2eFramework) ExecuteCqlNoAuth(k8sContext, namespace, pod, query string) (string, error)

func (*E2eFramework) GetCassandraDatacenterPods added in v1.2.0

func (f *E2eFramework) GetCassandraDatacenterPods(t *testing.T, ctx context.Context, dcKey ClusterKey, dcName string) ([]corev1.Pod, error)

GetCassandraPodIPs returns the Cassandra pods for a given cassdc.

func (*E2eFramework) GetContainerLogs added in v1.1.0

func (f *E2eFramework) GetContainerLogs(k8sContext, namespace, pod, container string) (string, error)

func (*E2eFramework) GetCqlClientConnection added in v1.4.0

func (f *E2eFramework) GetCqlClientConnection(
	ctx context.Context,
	k8sContext, namespace string,
	cqlEndpoint HostAndPort,
	username, password string,
	ssl bool,
) (*client.CqlClientConnection, error)

GetCqlClientConnection establishes a connection to the Stargate ingress's CQL port.

func (*E2eFramework) GetNodeToolStatus added in v0.5.0

func (f *E2eFramework) GetNodeToolStatus(k8sContext, namespace, pod string, additionalArgs ...string) (int, int, error)

GetNodeToolStatus Executes nodetool status against the Cassandra pod and returns a count of the matching lines reporting a status of Up/Normal and Down/Normal.

func (*E2eFramework) GetPodIP

func (f *E2eFramework) GetPodIP(k8sContext, namespace, pod string) (string, error)

func (*E2eFramework) GetStargateGrpcConnection added in v1.3.0

func (f *E2eFramework) GetStargateGrpcConnection(
	ctx context.Context,
	k8sContext, namespace, clusterName, username, password string,
	grpcEndpoint, authEndpoint HostAndPort,
) (*grpc.ClientConn, error)

func (*E2eFramework) InstallMinio added in v1.8.0

func (f *E2eFramework) InstallMinio() error

func (*E2eFramework) RetrieveDatabaseCredentials

func (f *E2eFramework) RetrieveDatabaseCredentials(ctx context.Context, k8sContext, namespace, clusterName string) (string, string, error)

func (*E2eFramework) RetrieveSuperuserSecret

func (f *E2eFramework) RetrieveSuperuserSecret(ctx context.Context, k8sContext, namespace, clusterName string) (*corev1.Secret, error)

func (*E2eFramework) UndeployAllIngresses

func (f *E2eFramework) UndeployAllIngresses(t *testing.T, k8sContext, namespace string)

func (*E2eFramework) WaitForCassOperatorToBeReady

func (f *E2eFramework) WaitForCassOperatorToBeReady(namespace string, timeout, interval time.Duration) error

WaitForCassOperatorToBeReady blocks until the cass-operator deployment is ready in the control plane and all data-planes.

func (*E2eFramework) WaitForCrdsToBecomeActive

func (f *E2eFramework) WaitForCrdsToBecomeActive() error

func (*E2eFramework) WaitForK8ssandraOperatorToBeReady

func (f *E2eFramework) WaitForK8ssandraOperatorToBeReady(namespace string, timeout, interval time.Duration) error

WaitForK8ssandraOperatorToBeReady blocks until the k8ssandra-operator deployment is ready in the control plane and all data planes.

type Framework

type Framework struct {
	// Client is the client for the control plane cluster, i.e., the cluster in which the
	// K8ssandraCluster controller is deployed. Note that this may also be one of the
	// data plane clients, if the control plane is being deployed in data plane.
	Client client.Client

	// The control plane, that is, the Kubernetes context in which the K8ssandraCluster controller
	// is running.
	ControlPlaneContext string

	// The data planes, that is, the Kubernetes contexts where K8ssandraCluster controller is going
	// to deploy datacenters. There must be at least one data plane defined.
	DataPlaneContexts []string
	// contains filtered or unexported fields
}

Framework provides methods for use in both integration and e2e tests.

func NewFramework

func NewFramework(client client.Client, controlPlaneContext string, dataPlaneContexts []string, remoteClients map[string]client.Client) *Framework

func (*Framework) AssertObjectDoesNotExist

func (f *Framework) AssertObjectDoesNotExist(ctx context.Context, t *testing.T, key ClusterKey, obj client.Object, timeout, interval time.Duration)

func (*Framework) CassTaskExists added in v1.5.0

func (f *Framework) CassTaskExists(ctx context.Context, key ClusterKey) func() bool

func (*Framework) ContainerHasEnvVar

func (f *Framework) ContainerHasEnvVar(container corev1.Container, envVarName, envVarValue string) bool

func (*Framework) ContainerHasVolumeMount

func (f *Framework) ContainerHasVolumeMount(container corev1.Container, volumeName, volumePath string) bool

func (*Framework) Create

func (f *Framework) Create(ctx context.Context, key ClusterKey, obj client.Object) error

func (*Framework) CreateNamespace

func (f *Framework) CreateNamespace(name string) error

func (*Framework) DatacenterExists

func (f *Framework) DatacenterExists(ctx context.Context, key ClusterKey) func() bool

func (*Framework) Delete

func (f *Framework) Delete(ctx context.Context, key ClusterKey, obj client.Object) error

func (*Framework) DeleteAllOf added in v1.1.0

func (f *Framework) DeleteAllOf(ctx context.Context, k8sContext string, obj client.Object, opts ...client.DeleteAllOfOption) error

func (*Framework) DeleteCassandraDatacenters

func (f *Framework) DeleteCassandraDatacenters(namespace string, timeout, interval time.Duration) error

func (*Framework) DeleteK8ssandraCluster

func (f *Framework) DeleteK8ssandraCluster(ctx context.Context, key client.ObjectKey, timeout time.Duration, interval time.Duration) error

func (*Framework) DeleteK8ssandraClusters

func (f *Framework) DeleteK8ssandraClusters(namespace string, timeout, interval time.Duration) error

func (*Framework) Get

func (f *Framework) Get(ctx context.Context, key ClusterKey, obj client.Object) error

Get fetches the object specified by key from the cluster specified by key. An error is returned is ClusterKey.K8sContext is not set or if there is no corresponding client.

func (*Framework) GetContactPointsService added in v1.20.0

func (f *Framework) GetContactPointsService(
	ctx context.Context, kcKey ClusterKey, kc *api.K8ssandraCluster, dcKey ClusterKey,
) (*corev1.Service, *corev1.Endpoints, error)

func (*Framework) K8ssandraTaskExists added in v1.5.0

func (f *Framework) K8ssandraTaskExists(ctx context.Context, key ClusterKey) func() bool

func (*Framework) List

func (f *Framework) List(ctx context.Context, key ClusterKey, obj client.ObjectList, opts ...client.ListOption) error

func (*Framework) MedusaConfigExists added in v1.12.0

func (f *Framework) MedusaConfigExists(ctx context.Context, k8sContext string, medusaConfigKey ClusterKey) func() bool

func (*Framework) NewAllPodsEndpoints added in v1.20.0

func (f *Framework) NewAllPodsEndpoints(
	kcKey ClusterKey, kc *api.K8ssandraCluster, dcKey ClusterKey, podIp string,
) *corev1.Endpoints

NewAllPodsEndpoints simulates the *-all-pods-service Endpoints that lists the nodes of a DC (in real life, this is done by the CassandraDatacenter's StatefulSet).

func (*Framework) NewWithCassTask added in v1.5.0

func (f *Framework) NewWithCassTask(ctx context.Context, key ClusterKey) func(func(*casstaskapi.CassandraTask) bool) func() bool

NewWithCassTask is a function generator for withCassandraTask that is bound to ctx, and key.

func (*Framework) NewWithDatacenter

func (f *Framework) NewWithDatacenter(ctx context.Context, key ClusterKey) func(func(*cassdcapi.CassandraDatacenter) bool) func() bool

NewWithDatacenter is a function generator for withDatacenter that is bound to ctx, and key.

func (*Framework) NewWithK8ssandraTask added in v1.5.0

func (f *Framework) NewWithK8ssandraTask(ctx context.Context, key ClusterKey) func(func(*k8taskapi.K8ssandraTask) bool) func() bool

NewWithK8ssandraTask is a function generator for withCassandraTask that is bound to ctx, and key.

func (*Framework) NewWithReaper

func (f *Framework) NewWithReaper(ctx context.Context, key ClusterKey) func(func(reaper *reaperapi.Reaper) bool) func() bool

NewWithReaper is a function generator for withReaper that is bound to ctx, and key.

func (*Framework) NewWithStargate

func (f *Framework) NewWithStargate(ctx context.Context, key ClusterKey) func(func(stargate *stargateapi.Stargate) bool) func() bool

NewWithStargate is a function generator for withStargate that is bound to ctx, and key.

func (*Framework) Patch

func (f *Framework) Patch(ctx context.Context, obj client.Object, patch client.Patch, key ClusterKey, opts ...client.PatchOption) error

func (*Framework) PatchCassandraTaskStatus added in v1.5.0

func (f *Framework) PatchCassandraTaskStatus(ctx context.Context, key ClusterKey, updateFn func(sg *casstaskapi.CassandraTask)) error

func (*Framework) PatchDatacenterStatus

func (f *Framework) PatchDatacenterStatus(ctx context.Context, key ClusterKey, updateFn func(dc *cassdcapi.CassandraDatacenter)) error

PatchDatacenterStatus fetches the datacenter specified by key, applies changes via updateFn, and then performs a patch operation. key.K8sContext must be set and must have a corresponding client.

func (*Framework) PatchDeploymentStatus added in v1.8.0

func (f *Framework) PatchDeploymentStatus(ctx context.Context, key ClusterKey, updateFn func(depl *appsv1.Deployment)) error

func (*Framework) PatchK8ssandraCluster added in v1.1.0

func (f *Framework) PatchK8ssandraCluster(ctx context.Context, key client.ObjectKey, updateFn func(kc *api.K8ssandraCluster)) error

PatchK8ssandraCluster fetches the K8ssandraCluster specified by key in the control plane, applies changes via updateFn, and then performs a patch operation.

func (*Framework) PatchReaperStatus

func (f *Framework) PatchReaperStatus(ctx context.Context, key ClusterKey, updateFn func(r *reaperapi.Reaper)) error

func (*Framework) PatchStargateStatus

func (f *Framework) PatchStargateStatus(ctx context.Context, key ClusterKey, updateFn func(sg *stargateapi.Stargate)) error

func (*Framework) PatchStatus added in v1.1.0

func (f *Framework) PatchStatus(ctx context.Context, obj client.Object, patch client.Patch, key ClusterKey, opts ...client.SubResourcePatchOption) error

func (*Framework) ReaperExists

func (f *Framework) ReaperExists(ctx context.Context, key ClusterKey) func() bool

func (*Framework) SetDatacenterStatusReady

func (f *Framework) SetDatacenterStatusReady(ctx context.Context, key ClusterKey) error

SetDatacenterStatusReady fetches the CassandraDatacenter specified by key and persists a status update to make the CassandraDatacenter ready. It sets the DatacenterReady and DatacenterInitialized conditions to true.

func (*Framework) SetDatacenterStatusStopped added in v0.5.0

func (f *Framework) SetDatacenterStatusStopped(ctx context.Context, key ClusterKey) error

SetDatacenterStatusStopped fetches the CassandraDatacenter specified by key and persists a status update to make the CassandraDatacenter stopped. It sets the DatacenterStopped and DatacenterInitialized conditions to true.

func (*Framework) SetMedusaDeplAvailable added in v1.8.0

func (f *Framework) SetMedusaDeplAvailable(ctx context.Context, key ClusterKey) error

SetDeploymentReplicas sets the replicas field of the given deployment to the given value.

func (*Framework) SetReaperStatusReady

func (f *Framework) SetReaperStatusReady(ctx context.Context, key ClusterKey) error

func (*Framework) SetStargateStatusReady

func (f *Framework) SetStargateStatusReady(ctx context.Context, key ClusterKey) error

func (*Framework) StargateExists

func (f *Framework) StargateExists(ctx context.Context, key ClusterKey) func() bool

func (*Framework) Update

func (f *Framework) Update(ctx context.Context, key ClusterKey, obj client.Object) error

func (*Framework) UpdateDatacenterGeneration added in v1.3.0

func (f *Framework) UpdateDatacenterGeneration(ctx context.Context, t *testing.T, key ClusterKey) bool

UpdateDatacenterGeneration fetches the CassandraDatacenter specified by key and persists a status update to make the ObservedGeneration match the Generation. It will wait for .meta.Generation to be different from .status.ObservedGeneration. This is done to simulate the behavior of the CassandraDatacenter controller.

func (*Framework) UpdateStatus

func (f *Framework) UpdateStatus(ctx context.Context, key ClusterKey, obj client.Object) error

func (*Framework) WaitForDeploymentToBeReady

func (f *Framework) WaitForDeploymentToBeReady(key ClusterKey, timeout, interval time.Duration) error

WaitForDeploymentToBeReady Blocks until the Deployment is ready. If ClusterKey.K8sContext is empty, this method blocks until the deployment is ready in all remote clusters.

type HostAndPort added in v1.1.0

type HostAndPort string

func (HostAndPort) Host added in v1.1.0

func (s HostAndPort) Host() string

func (HostAndPort) Port added in v1.1.0

func (s HostAndPort) Port() string

type OperatorDeploymentConfig

type OperatorDeploymentConfig struct {
	Namespace             string
	ClusterScoped         bool
	ImageName             string
	ImageTag              string
	MedusaImageTag        string
	GithubKustomization   bool // If true, use the kustomization.yaml from the github repo
	ControlPlaneComponent string
	DataPlaneComponent    string
}

type TestFixture added in v1.1.0

type TestFixture struct {

	// Name specifies the name of the fixture. The fixture name resolves to a subdirectory under the
	// test/testdata/fixtures directory.
	Name string

	// K8sContext is the name of the context where the fixture should be deployed.
	K8sContext string
	// contains filtered or unexported fields
}

TestFixture is a set of one or more yaml manifests, typically a manifest for a K8ssandraCluster. They are automatically deployed right before the test itself is executed.

func NewTestFixture added in v1.1.0

func NewTestFixture(name, k8sContext string) *TestFixture

Jump to

Keyboard shortcuts

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