Documentation ¶
Index ¶
- func AddEphemeralStorageToNode(node *apiv1.Node, eph int64) *apiv1.Node
- func AddGpuLabelToNode(node *apiv1.Node)
- func AddGpusToNode(node *apiv1.Node, gpusCount int64)
- func AddSchedulerName(schedulerName string) func(*apiv1.Pod)
- func BuildScheduledTestPod(name string, cpu, memory int64, nodeName string) *apiv1.Pod
- func BuildServiceTokenProjectedVolumeSource(path string) *apiv1.ProjectedVolumeSource
- func BuildTestNode(name string, millicpuCapacity int64, memCapacity int64) *apiv1.Node
- func BuildTestPod(name string, cpu int64, mem int64, options ...func(*apiv1.Pod)) *apiv1.Pod
- func BuildTestPodWithEphemeralStorage(name string, cpu, mem, ephemeralStorage int64) *apiv1.Pod
- func GenerateOwnerReferences(name, kind, api string, uid types.UID) []metav1.OwnerReference
- func GetGPULabel() string
- func MarkUnschedulable() func(*apiv1.Pod)
- func RemoveNodeNotReadyTaint(node *apiv1.Node)
- func RequestGpuForPod(pod *apiv1.Pod, gpusCount int64)
- func SetDSPodSpec(pod *apiv1.Pod) *apiv1.Pod
- func SetMirrorPodSpec(pod *apiv1.Pod) *apiv1.Pod
- func SetNodeCondition(node *apiv1.Node, conditionType apiv1.NodeConditionType, ...)
- func SetNodeNotReadyTaint(node *apiv1.Node)
- func SetNodeReadyState(node *apiv1.Node, ready bool, lastTransition time.Time)
- func SetRSPodSpec(pod *apiv1.Pod, rsName string) *apiv1.Pod
- func SetStaticPodSpec(pod *apiv1.Pod) *apiv1.Pod
- func TolerateGpuForPod(pod *apiv1.Pod)
- func WithAllocatable(node *apiv1.Node, millicpuAllocatable, memAllocatable int64) *apiv1.Node
- func WithDSController() func(*apiv1.Pod)
- func WithDeletionTimestamp(deletionTimestamp time.Time) func(*apiv1.Pod)
- func WithHostPort(hostport int32) func(*apiv1.Pod)
- func WithLabels(labels map[string]string) func(*apiv1.Pod)
- func WithMaxSkew(maxSkew int32, topologySpreadingKey string) func(*apiv1.Pod)
- func WithNamespace(namespace string) func(*apiv1.Pod)
- func WithNodeName(nodeName string) func(*apiv1.Pod)
- type HttpServerMock
- type HttpServerMockField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEphemeralStorageToNode ¶
AddEphemeralStorageToNode adds ephemeral storage capacity to a given node.
func AddGpuLabelToNode ¶
AddGpuLabelToNode adds GPULabel to give node. This is used to mock intermediate result that GPU on node is not ready
func AddGpusToNode ¶
AddGpusToNode adds GPU capacity to given node. Default accelerator type is used.
func AddSchedulerName ¶
AddSchedulerName adds scheduler name to a pod.
func BuildScheduledTestPod ¶
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 ¶
BuildTestNode creates a node with specified capacity.
func BuildTestPod ¶
BuildTestPod creates a pod with specified resources.
func BuildTestPodWithEphemeralStorage ¶
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 ¶
MarkUnschedulable marks pod as unschedulable.
func RemoveNodeNotReadyTaint ¶
RemoveNodeNotReadyTaint removes the not ready taint.
func RequestGpuForPod ¶
RequestGpuForPod modifies pod's resource requests by adding a number of GPUs to them.
func SetDSPodSpec ¶
SetDSPodSpec sets pod spec to make it a DS pod
func SetMirrorPodSpec ¶
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 ¶
SetNodeNotReadyTaint sets the not ready taint on node.
func SetNodeReadyState ¶
SetNodeReadyState sets node ready state to either ConditionTrue or ConditionFalse.
func SetRSPodSpec ¶
SetRSPodSpec sets pod spec to make it a RS pod
func SetStaticPodSpec ¶
SetStaticPodSpec sets pod spec to make it a static pod
func TolerateGpuForPod ¶
TolerateGpuForPod adds toleration for nvidia.com/gpu to Pod
func WithAllocatable ¶
WithAllocatable adds specified milliCpu and memory to Allocatable of the node in-place.
func WithDSController ¶
WithDSController creates a daemonSet owner ref for the pod.
func WithDeletionTimestamp ¶
WithDeletionTimestamp sets deletion timestamp to the pod.
func WithHostPort ¶
WithHostPort sets a namespace to the pod.
func WithLabels ¶
WithLabels sets a Labels to the pod.
func WithMaxSkew ¶
WithMaxSkew sets a namespace to the pod.
func WithNamespace ¶
WithNamespace sets a namespace to the pod.
func WithNodeName ¶
WithNodeName sets a node name to the pod.
Types ¶
type HttpServerMock ¶
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 )