helpers

package
v1.0.0-beta.13 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Package helpers includes helper functions important for unit and integration testing.

Index

Constants

View Source
const (

	// DefaultWWN specifies the default WWN.
	DefaultWWN = "eui.002538b411b2cee8"
	// DefaultWWN2 specifies the default WWN.
	DefaultWWN2 = "eui.0025388801b4dff2"
)

Variables

This section is empty.

Functions

func BareMetalHost

func BareMetalHost(name, namespace string, opts ...HostOpts) *infrav1.HetznerBareMetalHost

BareMetalHost returns a bare metal host given options.

func GetDefaultHetznerClusterSpec

func GetDefaultHetznerClusterSpec() infrav1.HetznerClusterSpec

GetDefaultHetznerClusterSpec returns the default Hetzner cluster spec.

func GetDefaultSSHSecret

func GetDefaultSSHSecret(name, namespace string) *corev1.Secret

GetDefaultSSHSecret returns the default ssh secret given name and namespace.

Types

type HostOpts

type HostOpts func(*infrav1.HetznerBareMetalHost)

HostOpts define options to customize the host spec.

func WithConsumerRef

func WithConsumerRef() HostOpts

WithConsumerRef gives the option to define a host with consumer ref.

func WithError

func WithError(errorType infrav1.ErrorType, errorMessage string, errorCount int, lastUpdated metav1.Time) HostOpts

WithError gives the option to define a host with error in spec.status.

func WithHetznerClusterRef

func WithHetznerClusterRef(hetznerClusterRef string) HostOpts

WithHetznerClusterRef gives the option to define a host with cluster ref.

func WithIPv4

func WithIPv4() HostOpts

WithIPv4 gives the option to define a host with IP.

func WithRebootTypes

func WithRebootTypes(rebootTypes []infrav1.RebootType) HostOpts

WithRebootTypes gives the option to define a host with custom reboot types.

func WithRootDeviceHintRaid

func WithRootDeviceHintRaid() HostOpts

WithRootDeviceHintRaid gives the option to define a host with root device hints.

func WithRootDeviceHintWWN

func WithRootDeviceHintWWN() HostOpts

WithRootDeviceHintWWN gives the option to define a host with root device hints.

func WithSSHSpec

func WithSSHSpec() HostOpts

WithSSHSpec gives the option to define a host with ssh spec.

func WithSSHSpecInclPorts

func WithSSHSpecInclPorts(portAfterInstallImage, portAfterCloudInit int) HostOpts

WithSSHSpecInclPorts gives the option to define a host with ssh spec incl. ports.

func WithSSHStatus

func WithSSHStatus() HostOpts

WithSSHStatus gives the option to define a host with ssh status.

type TestEnvironment

type TestEnvironment struct {
	ctrl.Manager
	client.Client
	Config                       *rest.Config
	HCloudClientFactory          hcloudclient.Factory
	RobotClientFactory           robotclient.Factory
	SSHClientFactory             sshclient.Factory
	RescueSSHClient              *sshmock.Client
	OSSSHClientAfterInstallImage *sshmock.Client
	OSSSHClientAfterCloudInit    *sshmock.Client
	RobotClient                  *robotmock.Client
	// contains filtered or unexported fields
}

TestEnvironment encapsulates a Kubernetes local test environment.

func NewTestEnvironment

func NewTestEnvironment() *TestEnvironment

NewTestEnvironment creates a new environment spinning up a local api-server.

func (*TestEnvironment) Cleanup

func (t *TestEnvironment) Cleanup(ctx context.Context, objs ...client.Object) error

Cleanup deletes client objects.

func (*TestEnvironment) CreateKubeconfigSecret

func (t *TestEnvironment) CreateKubeconfigSecret(ctx context.Context, cluster *clusterv1.Cluster) error

CreateKubeconfigSecret generates a kubeconfig secret in a given capi cluster.

func (*TestEnvironment) CreateNamespace

func (t *TestEnvironment) CreateNamespace(ctx context.Context, generateName string) (*corev1.Namespace, error)

CreateNamespace creates a namespace.

func (*TestEnvironment) StartManager

func (t *TestEnvironment) StartManager(ctx context.Context) error

StartManager starts the manager and sets a cancel function into the testEnv object.

func (*TestEnvironment) Stop

func (t *TestEnvironment) Stop() error

Stop stops the manager and cancels the context.

func (*TestEnvironment) WaitForWebhooks

func (t *TestEnvironment) WaitForWebhooks()

WaitForWebhooks waits for webhook port to be ready.

Jump to

Keyboard shortcuts

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