test

package
v0.0.0-...-148ffa3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEphemeralStorageToNode

func AddEphemeralStorageToNode(node *apiv1.Node, eph int64) *apiv1.Node

AddEphemeralStorageToNode adds ephemeral storage capacity to a given node.

func AddGpuLabelToNode

func AddGpuLabelToNode(node *apiv1.Node)

AddGpuLabelToNode adds GPULabel to give node. This is used to mock intermediate result that GPU on node is not ready

func AddGpusToNode

func AddGpusToNode(node *apiv1.Node, gpusCount int64)

AddGpusToNode adds GPU capacity to given node. Default accelerator type is used.

func AddSchedulerName

func AddSchedulerName(schedulerName string) func(*apiv1.Pod)

AddSchedulerName adds scheduler name to a pod.

func BuildScheduledTestPod

func BuildScheduledTestPod(name string, cpu, memory int64, nodeName string) *apiv1.Pod

BuildScheduledTestPod builds a scheduled test pod with a given spec

func BuildServiceTokenProjectedVolumeSource

func BuildServiceTokenProjectedVolumeSource(path string) *apiv1.ProjectedVolumeSource

BuildServiceTokenProjectedVolumeSource returns a ProjectedVolumeSource with SA token projection

func BuildTestNode

func BuildTestNode(name string, millicpuCapacity int64, memCapacity int64) *apiv1.Node

BuildTestNode creates a node with specified capacity.

func BuildTestPod

func BuildTestPod(name string, cpu int64, mem int64, options ...func(*apiv1.Pod)) *apiv1.Pod

BuildTestPod creates a pod with specified resources.

func BuildTestPodWithEphemeralStorage

func BuildTestPodWithEphemeralStorage(name string, cpu, mem, ephemeralStorage int64) *apiv1.Pod

BuildTestPodWithEphemeralStorage creates a pod with cpu, memory and ephemeral storage resources.

func GenerateOwnerReferences

func GenerateOwnerReferences(name, kind, api string, uid types.UID) []metav1.OwnerReference

GenerateOwnerReferences builds OwnerReferences with a single reference

func GetGPULabel

func GetGPULabel() string

GetGPULabel return GPULabel on the node. This is only used in unit tests.

func MarkUnschedulable

func MarkUnschedulable() func(*apiv1.Pod)

MarkUnschedulable marks pod as unschedulable.

func RemoveNodeNotReadyTaint

func RemoveNodeNotReadyTaint(node *apiv1.Node)

RemoveNodeNotReadyTaint removes the not ready taint.

func RequestGpuForPod

func RequestGpuForPod(pod *apiv1.Pod, gpusCount int64)

RequestGpuForPod modifies pod's resource requests by adding a number of GPUs to them.

func SetDSPodSpec

func SetDSPodSpec(pod *apiv1.Pod) *apiv1.Pod

SetDSPodSpec sets pod spec to make it a DS pod

func SetMirrorPodSpec

func SetMirrorPodSpec(pod *apiv1.Pod) *apiv1.Pod

SetMirrorPodSpec sets pod spec to make it a mirror pod

func SetNodeCondition

func SetNodeCondition(node *apiv1.Node, conditionType apiv1.NodeConditionType, status apiv1.ConditionStatus, lastTransition time.Time)

SetNodeCondition sets node condition.

func SetNodeNotReadyTaint

func SetNodeNotReadyTaint(node *apiv1.Node)

SetNodeNotReadyTaint sets the not ready taint on node.

func SetNodeReadyState

func SetNodeReadyState(node *apiv1.Node, ready bool, lastTransition time.Time)

SetNodeReadyState sets node ready state to either ConditionTrue or ConditionFalse.

func SetRSPodSpec

func SetRSPodSpec(pod *apiv1.Pod, rsName string) *apiv1.Pod

SetRSPodSpec sets pod spec to make it a RS pod

func SetStaticPodSpec

func SetStaticPodSpec(pod *apiv1.Pod) *apiv1.Pod

SetStaticPodSpec sets pod spec to make it a static pod

func TolerateGpuForPod

func TolerateGpuForPod(pod *apiv1.Pod)

TolerateGpuForPod adds toleration for nvidia.com/gpu to Pod

func WithAllocatable

func WithAllocatable(node *apiv1.Node, millicpuAllocatable, memAllocatable int64) *apiv1.Node

WithAllocatable adds specified milliCpu and memory to Allocatable of the node in-place.

func WithDSController

func WithDSController() func(*apiv1.Pod)

WithDSController creates a daemonSet owner ref for the pod.

func WithDeletionTimestamp

func WithDeletionTimestamp(deletionTimestamp time.Time) func(*apiv1.Pod)

WithDeletionTimestamp sets deletion timestamp to the pod.

func WithHostPort

func WithHostPort(hostport int32) func(*apiv1.Pod)

WithHostPort sets a namespace to the pod.

func WithLabels

func WithLabels(labels map[string]string) func(*apiv1.Pod)

WithLabels sets a Labels to the pod.

func WithMaxSkew

func WithMaxSkew(maxSkew int32, topologySpreadingKey string) func(*apiv1.Pod)

WithMaxSkew sets a namespace to the pod.

func WithNamespace

func WithNamespace(namespace string) func(*apiv1.Pod)

WithNamespace sets a namespace to the pod.

func WithNodeName

func WithNodeName(nodeName string) func(*apiv1.Pod)

WithNodeName sets a node name to the pod.

Types

type HttpServerMock

type HttpServerMock struct {
	mock.Mock
	*httptest.Server
	// contains filtered or unexported fields
}

HttpServerMock mocks server HTTP.

Example: // Create HttpServerMock. server := NewHttpServerMock() defer server.Close() // Use server.URL to point your code to HttpServerMock. g := newTestGceManager(t, server.URL, ModeGKE) // Declare handled urls and results for them. server.On("handle", "/project1/zones/us-central1-b/listManagedInstances").Return("<managedInstances>").Once() // Call http server in your code. instances, err := g.GetManagedInstances() // Check if expected calls were executed.

mock.AssertExpectationsForObjects(t, server)

Note: to provide a content type, you may pass in the desired fields: server := NewHttpServerMock(MockFieldContentType, MockFieldResponse) ... server.On("handle", "/project1/zones/us-central1-b/listManagedInstances").Return("<content type>", "<response>").Once() The order of the return objects must match that of the HttpServerMockField constants passed to NewHttpServerMock()

func NewHttpServerMock

func NewHttpServerMock(fields ...HttpServerMockField) *HttpServerMock

NewHttpServerMock creates new HttpServerMock.

type HttpServerMockField

type HttpServerMockField int

HttpServerMockField specifies a type of field.

const (
	// MockFieldResponse represents a string response.
	MockFieldResponse HttpServerMockField = iota
	// MockFieldStatusCode represents an integer HTTP response code.
	MockFieldStatusCode
	// MockFieldContentType represents a string content type.
	MockFieldContentType
	// MockFieldUserAgent represents a string user agent.
	MockFieldUserAgent
)

Jump to

Keyboard shortcuts

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