Documentation ¶
Overview ¶
Package testutils contains utility functions used by the unit tests of the resource-request-controller
Index ¶
- Constants
- func CheckResourceOfferUpdate(ctx context.Context, offerPrefix, homeClusterID, resourcesNamespace string, ...) bool
- func CreateNewNode(ctx context.Context, nodeName string, virtual bool, ...) (*corev1.Node, error)
- func CreateNewPod(ctx context.Context, podName, clusterID string, shadow bool, ...) (*corev1.Pod, error)
- func IsAllZero(resources *corev1.ResourceList) bool
- func Scale(percentage int64, resourceName corev1.ResourceName, ...)
- func SetNodeReadyStatus(ctx context.Context, node *corev1.Node, status bool, ...) (*corev1.Node, error)
- func SetPodReadyStatus(ctx context.Context, pod *corev1.Pod, status bool, ...) (*corev1.Pod, error)
Constants ¶
const DefaultScalePercentage = int64(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.