utils

package
v3.0.0-...-d6c4d9c Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 28 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

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

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

func GetClientsOrDie

func GetClientsOrDie() (ctrlruntimeclient.Client, rest.Interface, *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

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(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

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

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

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

type TestPodConfig struct {
	Log           *zap.SugaredLogger
	Namespace     string
	Client        ctrlruntimeclient.Client
	PodRestClient rest.Interface
	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

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

CleanUp deletes the resources.

func (*TestPodConfig) DeployTestPod

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

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