testutils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package testutils contains utility functions used by the unit tests of the resource-request-controller

Index

Constants

View Source
const DefaultScalePercentage = 50

DefaultScalePercentage defines the amount of scaled resources to be computed in resourceOffers.

Variables

This section is empty.

Functions

func CheckResourceOfferUpdate

func CheckResourceOfferUpdate(ctx context.Context, offerPrefix, homeClusterID, resourcesNamespace string,
	nodeResources, podResources []corev1.ResourceList, k8sClient client.Client) bool

CheckResourceOfferUpdate returns false if the (1) resource offer does not exist or the get returns an error (2) if the scaled quantity available in the resourceOffer is not equal to the one present in the cluster. It returns true otherwise.

func CreateNewNode

func CreateNewNode(ctx context.Context, nodeName string, virtual bool, clientset kubernetes.Interface) (*corev1.Node, error)

CreateNewNode forges a new node with name *nodeName* and creates it using the *clientset* client.

func CreateNewPod

func CreateNewPod(ctx context.Context, podName, clusterID string, shadow bool, clientset kubernetes.Interface) (*corev1.Pod, error)

CreateNewPod forges a new pod with name *podName* and creates it using the *clientset* client.

func IsAllZero

func IsAllZero(resources *corev1.ResourceList) bool

IsAllZero returns true if all the values in the ResourceList are zeroes. It returns false otherwise.

func Scale

func Scale(percentage int64, resourceName corev1.ResourceName, quantity *resource.Quantity)

Scale sets a *percentage* for a given *quantity* of a specific *resourceName*.

func SetNodeReadyStatus

func SetNodeReadyStatus(ctx context.Context, node *corev1.Node, status bool, clientset kubernetes.Interface) (*corev1.Node, error)

SetNodeReadyStatus enforces a status ready/not ready to a node passed as the *node* parameter. The readiness/not readiness is enforced by the *status* bool (true is ready, false is not ready).

func SetPodReadyStatus

func SetPodReadyStatus(ctx context.Context, pod *corev1.Pod, status bool, clientset kubernetes.Interface) (*corev1.Pod, error)

SetPodReadyStatus enforces a status ready/not ready to a pod passed as the *pod* parameter. The readiness/not readiness is enforced by the *status* bool (true is ready, false is not ready).

Types

This section is empty.

Jump to

Keyboard shortcuts

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