util

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package util contains all the utility methods to execute the test (APIServer interaction, wait for condition, etc.).

Index

Constants

View Source
const (
	// PodLocal -> the pod is local.
	PodLocal = "local"
	// PodRemote -> the pod is remote.
	PodRemote = "remote"
)

Variables

This section is empty.

Functions

func ArePodsUp

func ArePodsUp(ctx context.Context, clientset kubernetes.Interface, namespace string) (ready, notReady []string, retErr error)

ArePodsUp check if all the pods of a specific namespace are ready. It returns a list of ready pods, a list of unready pods and occurred errors.

func CheckIfTestIsSkipped added in v0.3.1

func CheckIfTestIsSkipped(t *testing.T, clustersRequired int, testName string)

CheckIfTestIsSkipped checks if the number of clusters required by the test is less than the number of cluster really present.

func CheckVirtualNodes

func CheckVirtualNodes(ctx context.Context, homeClusterClient kubernetes.Interface, clusterNumber int) (ready bool)

CheckVirtualNodes checks if the Liqo virtual nodes of cluster C.

func CreateNamespaceOffloading added in v0.3.1

CreateNamespaceOffloading creates a new NamespaceOffloading resource, with the given parameters.

func DescribeTableArgs added in v0.6.0

func DescribeTableArgs(itBody interface{}, entries ...ginkgo.TableEntry) []interface{}

DescribeTableArgs is an helper function to pack the arguments for DescribeTable, when entries are generated by an external function.

func EnforceNamespace

func EnforceNamespace(ctx context.Context, cl kubernetes.Interface, cluster discoveryv1alpha1.ClusterIdentity,
	name string) (*corev1.Namespace, error)

EnforceNamespace creates and returns a namespace. If it already exists, it just returns the namespace.

func EnsureNamespaceDeletion added in v0.3.1

func EnsureNamespaceDeletion(ctx context.Context, cl kubernetes.Interface, labelSelector map[string]string) error

EnsureNamespaceDeletion wrap the deletion of a namespace.

func ExecCmd

func ExecCmd(config *rest.Config, client kubernetes.Interface, podName, namespace, command string) (stdOut, stdErr string, retErr error)

ExecCmd executes a command inside a pod.

func ExecLiqoctl added in v0.5.0

func ExecLiqoctl(kubeconfig string, args []string, output io.Writer) error

ExecLiqoctl runs a liqoctl command targeting the cluster specified by the given kubeconfig.

func GetClusterLabels added in v0.3.1

func GetClusterLabels(index int) map[string]string

GetClusterLabels provides the labels which characterize the indexed cluster when exposed remotely as a virtual node.

func GetControllerClient added in v0.3.1

func GetControllerClient(scheme *runtime.Scheme, config *rest.Config) client.Client

GetControllerClient creates a new controller runtime client for the given config. If there is an error calls klog.Fatal().

func GetEnvironmentVariableOrDie added in v0.3.1

func GetEnvironmentVariableOrDie(key string) string

GetEnvironmentVariableOrDie retrieves the value of the environment variable named by the key. If the variable is not present calls klog.Fatal().

func GetNodes

func GetNodes(ctx context.Context, client kubernetes.Interface, clusterID, labelSelector string) (*v1.NodeList, error)

GetNodes returns the list of nodes of the cluster matching the given labels.

func GetRestConfigOrDie added in v0.3.1

func GetRestConfigOrDie(kubeconfig string) *rest.Config

GetRestConfigOrDie retrieves the rest.Config from the kubeconfig variable. If there is an error calls klog.Fatal().

func IsPodUp

func IsPodUp(ctx context.Context, client kubernetes.Interface, namespace, podName string, podType PodType) bool

IsPodUp waits for a specific namespace/podName to be ready. It returns true if the pod within the timeout, false otherwise.

func OffloadNamespace added in v0.5.0

func OffloadNamespace(kubeconfig, namespace string, args ...string) error

OffloadNamespace offloads a namespace using liqoctl.

func ResourceRequirements added in v0.6.0

func ResourceRequirements() corev1.ResourceRequirements

ResourceRequirements returns the default resource requirements for a pod during tests.

func TriggerCheckNodeConnectivity

func TriggerCheckNodeConnectivity(localNodes *v1.NodeList, command string, nodePortValue int) error

TriggerCheckNodeConnectivity checks nodePort service connectivity, executing a command for every node in the target cluster.

func UnoffloadNamespace added in v0.5.0

func UnoffloadNamespace(kubeconfig, namespace string) error

UnoffloadNamespace unoffloads a namespace using liqoctl.

Types

type PodType added in v0.3.2

type PodType string

PodType -> defines the type of a pod (local/remote).

Jump to

Keyboard shortcuts

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