utils

package
v2.24.12 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogOptions = log.Options{
	Debug:  false,
	Format: log.FormatConsole,
}

Functions

func CheckPodsRunningReady added in v2.17.0

func CheckPodsRunningReady(ctx context.Context, c ctrlruntimeclient.Client, log *zap.SugaredLogger, ns string, podNames []string, timeout time.Duration) bool

CheckPodsRunningReady returns whether all pods whose names are listed in podNames in namespace ns are running and ready, using c and waiting at most timeout.

func GetClients added in v2.17.0

func GetClients() (ctrlruntimeclient.Client, *rest.Config, error)

GetClients returns the clients used for testing or an error if something goes wrong during the clients creation.

func GetClientsOrDie added in v2.17.0

func GetClientsOrDie() (ctrlruntimeclient.Client, *rest.Config)

GetClientsOrDie returns the clients used for testing or panics if something goes wrong during the clients creation.

func KubernetesVersion

func KubernetesVersion() string

func PodRunningReady added in v2.17.0

func PodRunningReady(p *corev1.Pod) error

PodRunningReady checks whether pod p's phase is running and it has a ready condition of status true.

func WaitFor

func WaitFor(ctx context.Context, interval time.Duration, timeout time.Duration, callback func() bool) bool

WaitFor is a convenience wrapper that makes simple, "brute force" waiting loops easier to write.

func WaitForDeploymentReady added in v2.21.0

func WaitForDeploymentReady(ctx context.Context, c ctrlruntimeclient.Client, log *zap.SugaredLogger, ns, name string, timeout time.Duration) error

WaitForDeploymentReady waits until the Deployment is fully ready.

func WaitForPodCondition added in v2.17.0

func WaitForPodCondition(ctx context.Context, c ctrlruntimeclient.Client, log *zap.SugaredLogger, ns, podName, desc string, timeout time.Duration, condition podCondition) error

WaitForPodCondition waits a pods to be matched to the given condition.

func WaitForPodsCreated added in v2.17.0

func WaitForPodsCreated(ctx context.Context, c ctrlruntimeclient.Client, log *zap.SugaredLogger, replicas int, namespace string, matchLabels map[string]string) ([]string, error)

WaitForPodsCreated waits for the given replicas number of pods matching the given set of labels to be created, and returns the names of the matched pods.

Types

type TestPodConfig added in v2.17.0

type TestPodConfig struct {
	Log       *zap.SugaredLogger
	Namespace string
	Client    ctrlruntimeclient.Client
	Config    *rest.Config
	// CreatePodFunc returns the manifest of the pod to be used for running the
	// test. As we need to exec the pod should not terminate (e.g. run an
	// infinite sleep).
	CreatePodFunc       func(ns string) *corev1.Pod
	PodReadinessTimeout time.Duration
	// contains filtered or unexported fields
}

func (*TestPodConfig) CleanUp added in v2.17.0

func (t *TestPodConfig) CleanUp(ctx context.Context) error

CleanUp deletes the resources.

func (*TestPodConfig) DeployTestPod added in v2.17.0

func (t *TestPodConfig) DeployTestPod(ctx context.Context, log *zap.SugaredLogger) error

DeployTestPod deploys the pod to be used to run the test command.

func (*TestPodConfig) Exec added in v2.17.0

func (t *TestPodConfig) Exec(ctx context.Context, container string, command ...string) (string, string, error)

Exec executes the given command in the chosen container of the test pod.

Jump to

Keyboard shortcuts

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