helpers

package
v0.0.0-...-c894bf7 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestHelper

type TestHelper struct {
	*base.TestHelper
}

TestHelper is a collection of helpers for testing operators. It extends the generic TestHelper from modules/test.

func NewTestHelper

func NewTestHelper(
	ctx context.Context,
	k8sClient client.Client,
	timeout time.Duration,
	interval time.Duration,
	logger logr.Logger,
) *TestHelper

NewTestHelper returns a TestHelper

func (*TestHelper) CreateDBService

func (tc *TestHelper) CreateDBService(namespace string, mariadbCRName string, spec corev1.ServiceSpec) types.NamespacedName

CreateDBService creates a k8s Service object that matches with the Expectations of lib-common database module as a Service for the MariaDB

func (*TestHelper) CreateKeystoneAPI

func (tc *TestHelper) CreateKeystoneAPI(namespace string) types.NamespacedName

CreateKeystoneAPI creates a new KeystoneAPI instance with the specified namespace in the Kubernetes cluster.

Example usage:

keystoneAPI := th.CreateKeystoneAPI(namespace)
DeferCleanup(th.DeleteKeystoneAPI, keystoneAPI)

func (*TestHelper) CreateKeystoneAPIWithFixture

func (tc *TestHelper) CreateKeystoneAPIWithFixture(
	namespace string, fixture *apis.KeystoneAPIFixture,
) types.NamespacedName

CreateKeystoneAPIWithFixture creates a KeystoneAPI CR and configures its endpoints to point to the KeystoneAPIFixture that simulate the keystone-api behavior.

func (*TestHelper) CreateMemcached

func (tc *TestHelper) CreateMemcached(namespace string, memcachedName string, spec memcachedv1.MemcachedSpec) types.NamespacedName

CreateMemcached creates a new Memcached instance with the specified namespace in the Kubernetes cluster.

func (*TestHelper) DeleteDBService

func (tc *TestHelper) DeleteDBService(name types.NamespacedName)

DeleteDBService The function deletes the Service if exists and wait for it to disappear from the API. If the Service does not exists then it is assumed to be successfully deleted. Example:

th.DeleteDBService(types.NamespacedName{Name: "my-service", Namespace: "my-namespace"})

or:

DeferCleanup(th.DeleteDBService, th.CreateDBService(cell0.MariaDBDatabaseName.Namespace, cell0.MariaDBDatabaseName.Name, serviceSpec))

func (*TestHelper) DeleteKeystoneAPI

func (tc *TestHelper) DeleteKeystoneAPI(name types.NamespacedName)

DeleteKeystoneAPI deletes a KeystoneAPI resource from the Kubernetes cluster.

After the deletion, the function checks again if the KeystoneAPI is successfully deleted

Example usage:

keystoneAPI := th.CreateKeystoneAPI(namespace)
DeferCleanup(th.DeleteKeystoneAPI, keystoneAPI)

func (*TestHelper) DeleteMemcached

func (tc *TestHelper) DeleteMemcached(name types.NamespacedName)

DeleteMemcached deletes a Memcached instance from the Kubernetes cluster.

func (*TestHelper) GetKeystoneAPI

func (tc *TestHelper) GetKeystoneAPI(name types.NamespacedName) *keystonev1.KeystoneAPI

GetKeystoneAPI retrieves a KeystoneAPI resource.

The function returns a pointer to the retrieved KeystoneAPI resource. example usage:

  keystoneAPIName := th.CreateKeystoneAPI(novaNames.NovaName.Namespace)
	 DeferCleanup(th.DeleteKeystoneAPI, keystoneAPIName)
	 keystoneAPI := th.GetKeystoneAPI(keystoneAPIName)

func (*TestHelper) GetKeystoneEndpoint

func (tc *TestHelper) GetKeystoneEndpoint(name types.NamespacedName) *keystonev1.KeystoneEndpoint

GetKeystoneEndpoint retrieves a KeystoneEndpoint resource from the Kubernetes cluster.

Example usage:

keystoneEndpointName := th.CreateKeystoneEndpoint(namespace)

func (*TestHelper) GetKeystoneService

func (tc *TestHelper) GetKeystoneService(name types.NamespacedName) *keystonev1.KeystoneService

GetKeystoneService function retrieves and returns the KeystoneService resource

Example usage:

keystoneServiceName := th.CreateKeystoneService(namespace)

func (*TestHelper) GetMariaDBDatabase

func (tc *TestHelper) GetMariaDBDatabase(name types.NamespacedName) *mariadbv1.MariaDBDatabase

GetMariaDBDatabase waits for and retrieves a MariaDBDatabase resource from the Kubernetes cluster

Example:

mariadbDatabase := th.GetMariaDBDatabase(types.NamespacedName{Name: "my-mariadb-database", Namespace: "my-namespace"})

func (*TestHelper) GetMemcached

func (tc *TestHelper) GetMemcached(name types.NamespacedName) *memcachedv1.Memcached

GetMemcached waits for and retrieves a Memcached instance from the Kubernetes cluster

func (*TestHelper) GetTransportURL

func (tc *TestHelper) GetTransportURL(name types.NamespacedName) *rabbitmqv1.TransportURL

GetTransportURL retrieves a TransportURL resource with the specified name.

Example usage:

th.GetTransportURL(types.NamespacedName{Name: "test-transporturl", Namespace: "test-namespace"})

func (*TestHelper) SimulateKeystoneEndpointReady

func (tc *TestHelper) SimulateKeystoneEndpointReady(name types.NamespacedName)

SimulateKeystoneEndpointReady function retrieves the KeystoneEndpoint resource and simulates a KeystoneEndpoint resource being marked as ready.

Example usage:

keystoneEndpointName := th.CreateKeystoneEndpoint(namespace)
th.SimulateKeystoneEndpointReady(keystoneEndpointName)

func (*TestHelper) SimulateKeystoneServiceReady

func (tc *TestHelper) SimulateKeystoneServiceReady(name types.NamespacedName)

SimulateKeystoneServiceReady simulates the readiness of a KeystoneService resource by seting the Ready condition of the KeystoneService to true

Example usage: keystoneServiceName := th.CreateKeystoneService(namespace)

func (*TestHelper) SimulateMariaDBDatabaseCompleted

func (tc *TestHelper) SimulateMariaDBDatabaseCompleted(name types.NamespacedName)

SimulateMariaDBDatabaseCompleted simulates a completed state for a MariaDBDatabase resource in a Kubernetes cluster.

Example:

th.SimulateMariaDBDatabaseCompleted(types.NamespacedName{Name: "my-mariadb-database", Namespace: "my-namespace"})

or

DeferCleanup(th.SimulateMariaDBDatabaseCompleted, types.NamespacedName{Name: "my-mariadb-database", Namespace: "my-namespace"})

func (*TestHelper) SimulateMemcachedReady

func (tc *TestHelper) SimulateMemcachedReady(name types.NamespacedName)

SimulateMemcachedReady simulates a ready state for a Memcached instance in a Kubernetes cluster.

func (*TestHelper) SimulateTransportURLReady

func (tc *TestHelper) SimulateTransportURLReady(name types.NamespacedName)

SimulateTransportURLReady function retrieves the TransportURL and simulates the readiness of a TransportURL resource.

Example usage:

th.SimulateTransportURLReady(types.NamespacedName{Name: "test-transporturl", Namespace: "test-namespace"})

Jump to

Keyboard shortcuts

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