util

package
v0.3.2-beta.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 24 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

func CreateNamespaceOffloading(ctx context.Context, cl client.Client, namespaceName string,
	namespaceMappingStrategy offv1alpha1.NamespaceMappingStrategyType,
	podStrategy offv1alpha1.PodOffloadingStrategyType,
	clusterSelector *corev1.NodeSelector) error

CreateNamespaceOffloading gets the right NamespaceOffloading according to the specified strategy.

func EnforceNamespace

func EnforceNamespace(ctx context.Context, cl kubernetes.Interface, clusterID, name string,
	namespaceLabels map[string]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 GetClusterID added in v0.3.1

func GetClusterID(ctx context.Context, cl kubernetes.Interface, namespace string) (string, error)

GetClusterID provides the clusterID for the cluster associated with the client.

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 GetClusterSelector added in v0.3.1

func GetClusterSelector() *corev1.NodeSelector

GetClusterSelector returns a cluster selector for a NamespaceOffloading resource.

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 GetNamespaceLabel added in v0.3.1

func GetNamespaceLabel(enablingLiqo bool) map[string]string

GetNamespaceLabel sets the labels on the namespace just created. If "enablingLiqo" is set to true it adds the enabling liqo label to the namespace, so a default NamespaceOffloading resource is created for that namespace.

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

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