Documentation
¶
Overview ¶
Package util contains all the utility methods to execute the test (APIServer interaction, wait for condition, etc.).
Index ¶
- Constants
- func ActivateTenants(ctx context.Context, cl client.Client) error
- func AddArgumentToDeployment(ctx context.Context, cl client.Client, namespace, name, argument string, ...) error
- func ArePodsUp(ctx context.Context, clientset kubernetes.Interface, namespace string) (ready, notReady []string, retErr error)
- func CheckIfTestIsSkipped(t *testing.T, clustersRequired int, testName string)
- func CheckVirtualNodes(ctx context.Context, homeClusterClient kubernetes.Interface, clusterNumber int) (ready bool)
- func CordonTenants(ctx context.Context, cl client.Client) error
- func CreateNamespaceOffloading(ctx context.Context, cl client.Client, namespace string, ...) error
- func DeleteResource(ctx context.Context, cl client.Client, obj client.Object) error
- func DescribeTableArgs(itBody interface{}, entries ...ginkgo.TableEntry) []interface{}
- func DrainTenants(ctx context.Context, cl client.Client) error
- func EnforceConfigMap(ctx context.Context, cl client.Client, namespace, name string, ...) error
- func EnforceDeployment(ctx context.Context, cl client.Client, namespace, name string, ...) error
- func EnforceEvent(ctx context.Context, cl client.Client, namespace, name string, ...) error
- func EnforceIngress(ctx context.Context, cl client.Client, namespace, name string, ...) error
- func EnforceNamespace(ctx context.Context, cl kubernetes.Interface, cluster liqov1beta1.ClusterID, ...) (*corev1.Namespace, error)
- func EnforcePod(ctx context.Context, cl client.Client, namespace, name string, ...) error
- func EnforceSecret(ctx context.Context, cl client.Client, namespace, name string, ...) error
- func EnforceService(ctx context.Context, cl client.Client, namespace, name string, ...) error
- func EnsureDeploymentDeletion(ctx context.Context, cl client.Client, namespace, name string) error
- func EnsureNamespaceDeletion(ctx context.Context, cl kubernetes.Interface, name string) error
- func EnsureNamespacesDeletionWithSelector(ctx context.Context, cl kubernetes.Interface, labelSelector map[string]string) error
- func ExecCmd(ctx context.Context, config *rest.Config, client kubernetes.Interface, ...) (stdOut, stdErr string, retErr error)
- func ExecLiqoctl(kubeconfig string, args []string, output io.Writer) error
- func First[F any, S any](first F, _ S) F
- func GetClusterLabels(index int) map[string]string
- func GetControllerClient(scheme *runtime.Scheme, config *rest.Config) client.Client
- func GetEnvironmentVariableOrDie(key string) string
- func GetNameNamespaceTest(testName string) string
- func GetNamespaceOffloading(ctx context.Context, cl client.Client, namespace string) (*offloadingv1beta1.NamespaceOffloading, error)
- func GetNodes(ctx context.Context, client kubernetes.Interface, ...) (*corev1.NodeList, error)
- func GetPodsFromDeployment(ctx context.Context, cl client.Client, namespace, name string) ([]corev1.Pod, error)
- func GetResource(ctx context.Context, cl client.Client, obj client.Object) error
- func GetRestConfigOrDie(kubeconfig string) *rest.Config
- func GetWorkerNodes(ctx context.Context, client kubernetes.Interface, ...) (*corev1.NodeList, error)
- func IsNodeControlPlane(taints []corev1.Taint) bool
- func IsPodUp(ctx context.Context, clientset kubernetes.Interface, namespace, podName string, ...) bool
- func NumPodsInTenantNs(networkingEnabled bool, role liqov1beta1.RoleType, gwReplicas, vkReplicas int) int
- func NumTenantNamespaces(numPeeredConsumers, numPeeredProviders int, role liqov1beta1.RoleType) int
- func OffloadNamespace(kubeconfig, namespace string, args ...string) error
- func RemoveArgumentFromDeployment(ctx context.Context, cl client.Client, namespace, name, argument string, ...) error
- func ResourceRequirements() corev1.ResourceRequirements
- func Second[F any, S any](_ F, second S) S
- func TriggerCheckNodeConnectivity(localNodes *v1.NodeList, command string, nodePortValue int) error
- func UnoffloadNamespace(kubeconfig, namespace string) error
- type ConfigMapOption
- type DeploymentOption
- type EventOption
- type IngressOption
- type PodOption
- type PodType
- type SecretOption
- type ServiceOption
Constants ¶
const ( // PodLocal -> the pod is local. PodLocal = "local" // PodRemote -> the pod is remote. PodRemote = "remote" )
Variables ¶
This section is empty.
Functions ¶
func ActivateTenants ¶ added in v1.0.0
ActivateTenants sets the TenantCondition of all Tenants to Active.
func AddArgumentToDeployment ¶ added in v1.0.0
func AddArgumentToDeployment(ctx context.Context, cl client.Client, namespace, name, argument string, index int) error
AddArgumentToDeployment adds an argument to the containers of a Deployment with the given name in the given namespace.
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
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 CordonTenants ¶ added in v1.0.0
CordonTenants sets the TenantCondition of all Tenants to Cordoned.
func CreateNamespaceOffloading ¶ added in v0.3.1
func CreateNamespaceOffloading(ctx context.Context, cl client.Client, namespace string, nms offloadingv1beta1.NamespaceMappingStrategyType, pof offloadingv1beta1.PodOffloadingStrategyType) error
CreateNamespaceOffloading creates a new NamespaceOffloading resource, with the given parameters.
func DeleteResource ¶ added in v1.0.0
DeleteResource deletes a generic Resource given its metadata.
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 DrainTenants ¶ added in v1.0.0
DrainTenants sets the TenantCondition of all Tenants to Drained.
func EnforceConfigMap ¶ added in v1.0.0
func EnforceConfigMap(ctx context.Context, cl client.Client, namespace, name string, options ...ConfigMapOption) error
EnforceConfigMap creates or updates a ConfigMap with the given name in the given namespace.
func EnforceDeployment ¶ added in v1.0.0
func EnforceDeployment(ctx context.Context, cl client.Client, namespace, name string, options ...DeploymentOption) error
EnforceDeployment creates or updates a Deployment with the given name in the given namespace.
func EnforceEvent ¶ added in v1.0.0
func EnforceEvent(ctx context.Context, cl client.Client, namespace, name string, involvedObject *corev1.ObjectReference, options ...EventOption) error
EnforceEvent creates or updates a Event with the given name in the given namespace.
func EnforceIngress ¶ added in v1.0.0
func EnforceIngress(ctx context.Context, cl client.Client, namespace, name string, options ...IngressOption) error
EnforceIngress creates or updates a Ingress with the given name in the given namespace.
func EnforceNamespace ¶
func EnforceNamespace(ctx context.Context, cl kubernetes.Interface, cluster liqov1beta1.ClusterID, name string) (*corev1.Namespace, error)
EnforceNamespace creates and returns a namespace. If it already exists, it just returns the namespace.
func EnforcePod ¶ added in v1.0.0
func EnforcePod(ctx context.Context, cl client.Client, namespace, name string, options ...PodOption) error
EnforcePod creates or updates a Pod with the given name in the given namespace.
func EnforceSecret ¶ added in v1.0.0
func EnforceSecret(ctx context.Context, cl client.Client, namespace, name string, options ...SecretOption) error
EnforceSecret creates or updates a Secret with the given name in the given namespace.
func EnforceService ¶ added in v1.0.0
func EnforceService(ctx context.Context, cl client.Client, namespace, name string, options ...ServiceOption) error
EnforceService creates or updates a Service with the given name in the given namespace.
func EnsureDeploymentDeletion ¶ added in v1.0.0
EnsureDeploymentDeletion deletes a Deployment with the given name in the given namespace.
func EnsureNamespaceDeletion ¶ added in v0.3.1
EnsureNamespaceDeletion deletes the namespace with the given name.
func EnsureNamespacesDeletionWithSelector ¶ added in v1.0.0
func EnsureNamespacesDeletionWithSelector(ctx context.Context, cl kubernetes.Interface, labelSelector map[string]string) error
EnsureNamespacesDeletionWithSelector wrap the deletion of namespaces matching the given labelSelector.
func ExecCmd ¶
func ExecCmd(ctx context.Context, 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
ExecLiqoctl runs a liqoctl command targeting the cluster specified by the given kubeconfig.
func GetClusterLabels ¶ added in v0.3.1
GetClusterLabels provides the labels which characterize the indexed cluster when exposed remotely as a virtual node.
func GetControllerClient ¶ added in v0.3.1
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
GetEnvironmentVariableOrDie retrieves the value of the environment variable named by the key. If the variable is not present calls klog.Fatal().
func GetNameNamespaceTest ¶ added in v1.0.0
GetNameNamespaceTest returns the name of the namespace where resources for the test are created.
func GetNamespaceOffloading ¶ added in v1.0.0
func GetNamespaceOffloading(ctx context.Context, cl client.Client, namespace string) (*offloadingv1beta1.NamespaceOffloading, error)
GetNamespaceOffloading returns the NamespaceOffloading resource for the given namespace.
func GetNodes ¶
func GetNodes(ctx context.Context, client kubernetes.Interface, clusterID liqov1beta1.ClusterID, labelSelector string) (*corev1.NodeList, error)
GetNodes returns the list of nodes of the cluster matching the given labels.
func GetPodsFromDeployment ¶ added in v1.0.0
func GetPodsFromDeployment(ctx context.Context, cl client.Client, namespace, name string) ([]corev1.Pod, error)
GetPodsFromDeployment returns the Pods of a Deployment with the given name in the given namespace.
func GetResource ¶ added in v1.0.0
GetResource retrieves a generic Resource.
func GetRestConfigOrDie ¶ added in v0.3.1
GetRestConfigOrDie retrieves the rest.Config from the kubeconfig variable. If there is an error calls klog.Fatal().
func GetWorkerNodes ¶ added in v1.0.0
func GetWorkerNodes(ctx context.Context, client kubernetes.Interface, clusterID, labelSelector string) (*corev1.NodeList, error)
GetWorkerNodes returns the list of worker nodes of the cluster.
func IsNodeControlPlane ¶ added in v1.0.0
IsNodeControlPlane checks if the node has the control-plane taint.
func IsPodUp ¶
func IsPodUp(ctx context.Context, clientset 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 NumPodsInTenantNs ¶ added in v1.0.0
func NumPodsInTenantNs(networkingEnabled bool, role liqov1beta1.RoleType, gwReplicas, vkReplicas int) int
NumPodsInTenantNs returns the number of pods that should be present in a tenant namespace.
func NumTenantNamespaces ¶ added in v1.0.0
func NumTenantNamespaces(numPeeredConsumers, numPeeredProviders int, role liqov1beta1.RoleType) int
NumTenantNamespaces returns the number of tenant namespaces that should be present in a cluster.
func OffloadNamespace ¶ added in v0.5.0
OffloadNamespace offloads a namespace using liqoctl.
func RemoveArgumentFromDeployment ¶ added in v1.0.0
func RemoveArgumentFromDeployment(ctx context.Context, cl client.Client, namespace, name, argument string, index int) error
RemoveArgumentFromDeployment removes an argument from the containers of a Deployment with the given name in the given namespace.
func ResourceRequirements ¶ added in v0.6.0
func ResourceRequirements() corev1.ResourceRequirements
ResourceRequirements returns the default resource requirements for a pod during tests.
func TriggerCheckNodeConnectivity ¶
TriggerCheckNodeConnectivity checks nodePort service connectivity, executing a command for every node in the target cluster.
func UnoffloadNamespace ¶ added in v0.5.0
UnoffloadNamespace unoffloads a namespace using liqoctl.
Types ¶
type ConfigMapOption ¶ added in v1.0.0
ConfigMapOption is a function that modifies a ConfigMap.
type DeploymentOption ¶ added in v1.0.0
type DeploymentOption func(*appsv1.Deployment)
DeploymentOption is a function that modifies a Deployment.
func LocalDeploymentOption ¶ added in v1.0.0
func LocalDeploymentOption() DeploymentOption
LocalDeploymentOption sets the Deployment to be scheduled on local nodes.
func RemoteDeploymentOption ¶ added in v1.0.0
func RemoteDeploymentOption() DeploymentOption
RemoteDeploymentOption sets the Deployment to be scheduled on remote nodes.
func RuntimeClassOption ¶ added in v1.0.0
func RuntimeClassOption(runtimeClass string) DeploymentOption
RuntimeClassOption sets the RuntimeClass of the Deployment.
type EventOption ¶ added in v1.0.0
EventOption is a function that modifies a Event.
type IngressOption ¶ added in v1.0.0
IngressOption is a function that modifies a Ingress.
type PodOption ¶ added in v1.0.0
PodOption is a function that modifies a Pod.
func RemotePodOption ¶ added in v1.0.0
RemotePodOption sets the Pod to be scheduled on remote nodes.
type PodType ¶ added in v0.3.2
type PodType string
PodType -> defines the type of a pod (local/remote).
type SecretOption ¶ added in v1.0.0
SecretOption is a function that modifies a Secret.
type ServiceOption ¶ added in v1.0.0
ServiceOption is a function that modifies a Service.
func WithNodePort ¶ added in v1.0.0
func WithNodePort() ServiceOption
WithNodePort sets the Service type to NodePort.