Documentation ¶
Index ¶
- Constants
- func AddTaintToNode(cs clientset.Interface, nodeName string, taint v1.Taint) error
- func CleanupNodes(cs clientset.Interface, t *testing.T)
- func CleanupPods(cs clientset.Interface, t *testing.T, pods []*v1.Pod)
- func CleanupTest(t *testing.T, testCtx *TestContext)
- func CreateAndWaitForNodesInCache(testCtx *TestContext, prefix string, wrapper *st.NodeWrapper, numNodes int) ([]*v1.Node, error)
- func CreateNamespacesWithLabels(cs clientset.Interface, namespaces []string, labels map[string]string) error
- func CreateNode(cs clientset.Interface, node *v1.Node) (*v1.Node, error)
- func CreatePV(cs clientset.Interface, pv *v1.PersistentVolume) (*v1.PersistentVolume, error)
- func CreatePVC(cs clientset.Interface, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
- func CreatePausePod(cs clientset.Interface, p *v1.Pod) (*v1.Pod, error)
- func CreatePausePodWithResource(cs clientset.Interface, podName string, nsName string, res *v1.ResourceList) (*v1.Pod, error)
- func DeletePod(cs clientset.Interface, podName string, nsName string) error
- func GetPod(cs clientset.Interface, podName string, podNamespace string) (*v1.Pod, error)
- func GetTolerationSeconds(tolerations []v1.Toleration) (int64, error)
- func InitDisruptionController(t *testing.T, testCtx *TestContext) *disruption.DisruptionController
- func InitPausePod(conf *PausePodConfig) *v1.Pod
- func InitPodWithContainers(cs clientset.Interface, conf *PodWithContainersConfig) *v1.Pod
- func NewMockGCECloud(cloud cloud.Cloud) (*gce.Cloud, error)
- func NextPod(t *testing.T, testCtx *TestContext) *schedulerframework.QueuedPodInfo
- func NextPodOrDie(t *testing.T, testCtx *TestContext) *schedulerframework.QueuedPodInfo
- func NodeCopyWithConditions(node *v1.Node, conditions []v1.NodeCondition) *v1.Node
- func NodeReadyStatus(conditions []v1.NodeCondition) (v1.ConditionStatus, error)
- func NodeTainted(cs clientset.Interface, nodeName string, taints []v1.Taint) wait.ConditionFunc
- func PodDeleted(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
- func PodIsGettingEvicted(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
- func PodScheduled(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
- func PodScheduledIn(c clientset.Interface, podNamespace, podName string, nodeNames []string) wait.ConditionFunc
- func PodSchedulingError(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
- func PodSchedulingGated(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
- func PodUnschedulable(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
- func RemovePodFinalizers(cs clientset.Interface, t *testing.T, pods []*v1.Pod)
- func RemoveTaintOffNode(cs clientset.Interface, nodeName string, taint v1.Taint) error
- func RunPausePod(cs clientset.Interface, pod *v1.Pod) (*v1.Pod, error)
- func RunPodWithContainers(cs clientset.Interface, pod *v1.Pod) (*v1.Pod, error)
- func SyncInformerFactory(testCtx *TestContext)
- func UpdateNode(cs clientset.Interface, node *v1.Node) (*v1.Node, error)
- func UpdateNodeStatus(cs clientset.Interface, node *v1.Node) error
- func WaitCachedPodsStable(testCtx *TestContext, pods []*v1.Pod) error
- func WaitForNodeTaints(cs clientset.Interface, node *v1.Node, taints []v1.Taint) error
- func WaitForNodesInCache(sched *scheduler.Scheduler, nodeCount int) error
- func WaitForPDBsStable(testCtx *TestContext, pdbs []*policy.PodDisruptionBudget, pdbPodNum []int32) error
- func WaitForPodSchedulingGated(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error
- func WaitForPodToSchedule(cs clientset.Interface, pod *v1.Pod) error
- func WaitForPodToScheduleWithTimeout(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error
- func WaitForPodUnschedulable(cs clientset.Interface, pod *v1.Pod) error
- func WaitForPodUnschedulableWithTimeout(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error
- func WaitForReflection(t *testing.T, nodeLister corelisters.NodeLister, key string, ...) error
- func WaitForSchedulerCacheCleanup(sched *scheduler.Scheduler, t *testing.T)
- type PausePodConfig
- type PodWithContainersConfig
- type ShutdownFunc
- type TestContext
- func InitTestAPIServer(t *testing.T, nsPrefix string, admission admission.Interface) *TestContext
- func InitTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext
- func InitTestScheduler(t *testing.T, testCtx *TestContext) *TestContext
- func InitTestSchedulerWithNS(t *testing.T, nsPrefix string, opts ...scheduler.Option) *TestContext
- func InitTestSchedulerWithOptions(t *testing.T, testCtx *TestContext, resyncPeriod time.Duration, ...) *TestContext
Constants ¶
const ( // TestProjectID is the project id used for creating NewMockGCECloud TestProjectID = "test-project" // TestNetworkProjectID is the network project id for creating NewMockGCECloud TestNetworkProjectID = "net-test-project" // TestRegion is the region for creating NewMockGCECloud TestRegion = "test-region" // TestZone is the zone for creating NewMockGCECloud TestZone = "test-zone" // TestNetworkName is the network name for creating NewMockGCECloud TestNetworkName = "test-network" // TestSubnetworkName is the sub network name for creating NewMockGCECloud TestSubnetworkName = "test-sub-network" // TestSecondaryRangeName is the secondary range name for creating NewMockGCECloud TestSecondaryRangeName = "test-secondary-range" )
Variables ¶
This section is empty.
Functions ¶
func AddTaintToNode ¶ added in v1.18.0
AddTaintToNode add taints to specific node
func CleanupNodes ¶ added in v1.18.0
CleanupNodes cleans all nodes which were created during integration test
func CleanupPods ¶ added in v1.18.0
CleanupPods deletes the given pods and waits for them to be actually deleted.
func CleanupTest ¶ added in v1.18.0
func CleanupTest(t *testing.T, testCtx *TestContext)
CleanupTest cleans related resources which were created during integration test
func CreateAndWaitForNodesInCache ¶ added in v1.24.10
func CreateAndWaitForNodesInCache(testCtx *TestContext, prefix string, wrapper *st.NodeWrapper, numNodes int) ([]*v1.Node, error)
CreateAndWaitForNodesInCache calls createNodes(), and wait for the created nodes to be present in scheduler cache.
func CreateNamespacesWithLabels ¶ added in v1.24.10
func CreateNode ¶ added in v1.24.10
func CreatePV ¶ added in v1.26.0
func CreatePV(cs clientset.Interface, pv *v1.PersistentVolume) (*v1.PersistentVolume, error)
CreatePV creates a PersistentVolume with the given config and returns its pointer and error status.
func CreatePVC ¶ added in v1.26.0
func CreatePVC(cs clientset.Interface, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
CreatePVC creates a PersistentVolumeClaim with the given config and returns its pointer and error status.
func CreatePausePod ¶ added in v1.24.10
CreatePausePod creates a pod with "Pause" image and the given config and return its pointer and error status.
func CreatePausePodWithResource ¶ added in v1.24.10
func CreatePausePodWithResource(cs clientset.Interface, podName string, nsName string, res *v1.ResourceList) (*v1.Pod, error)
CreatePausePodWithResource creates a pod with "Pause" image and the given resources and returns its pointer and error status. The resource list can be nil.
func GetTolerationSeconds ¶ added in v1.18.0
func GetTolerationSeconds(tolerations []v1.Toleration) (int64, error)
GetTolerationSeconds gets the period of time the toleration
func InitDisruptionController ¶ added in v1.24.10
func InitDisruptionController(t *testing.T, testCtx *TestContext) *disruption.DisruptionController
InitDisruptionController initializes and runs a Disruption Controller to properly update PodDisuptionBudget objects.
func InitPausePod ¶ added in v1.24.10
func InitPausePod(conf *PausePodConfig) *v1.Pod
InitPausePod initializes a pod API object from the given config. It is used mainly in pod creation process.
func InitPodWithContainers ¶ added in v1.24.10
func InitPodWithContainers(cs clientset.Interface, conf *PodWithContainersConfig) *v1.Pod
InitPodWithContainers initializes a pod API object from the given config. This is used primarily for generating pods with containers each having a specific image.
func NewMockGCECloud ¶ added in v1.11.0
NewMockGCECloud returns a handle to a Cloud instance that is served by a mock http server
func NextPod ¶ added in v1.24.10
func NextPod(t *testing.T, testCtx *TestContext) *schedulerframework.QueuedPodInfo
NextPod returns the next Pod in the scheduler queue, with a 5 seconds timeout.
func NextPodOrDie ¶ added in v1.24.10
func NextPodOrDie(t *testing.T, testCtx *TestContext) *schedulerframework.QueuedPodInfo
NextPodOrDie returns the next Pod in the scheduler queue. The operation needs to be completed within 5 seconds; otherwise the test gets aborted.
func NodeCopyWithConditions ¶ added in v1.18.0
NodeCopyWithConditions duplicates the ode object with conditions
func NodeReadyStatus ¶ added in v1.18.0
func NodeReadyStatus(conditions []v1.NodeCondition) (v1.ConditionStatus, error)
NodeReadyStatus returns the status of first condition with type NodeReady. If none of the condition is of type NodeReady, returns an error.
func NodeTainted ¶ added in v1.18.0
NodeTainted return a condition function that returns true if the given node contains the taints.
func PodDeleted ¶ added in v1.18.0
func PodDeleted(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
PodDeleted returns true if a pod is not found in the given namespace.
func PodIsGettingEvicted ¶ added in v1.24.10
func PodIsGettingEvicted(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
PodIsGettingEvicted returns true if the pod's deletion timestamp is set.
func PodScheduled ¶ added in v1.18.0
func PodScheduled(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
PodScheduled checks if the pod has been scheduled
func PodScheduledIn ¶ added in v1.24.10
func PodScheduledIn(c clientset.Interface, podNamespace, podName string, nodeNames []string) wait.ConditionFunc
PodScheduledIn returns true if a given pod is placed onto one of the expected nodes.
func PodSchedulingError ¶ added in v1.24.10
func PodSchedulingError(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
PodSchedulingError returns a condition function that returns true if the given pod gets unschedulable status for reasons other than "Unschedulable". The scheduler records such reasons in case of error.
func PodSchedulingGated ¶ added in v1.26.0
func PodSchedulingGated(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
PodSchedulingGated returns a condition function that returns true if the given pod gets unschedulable status of reason 'SchedulingGated'.
func PodUnschedulable ¶ added in v1.24.10
func PodUnschedulable(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc
PodUnschedulable returns a condition function that returns true if the given pod gets unschedulable status of reason 'Unschedulable'.
func RemovePodFinalizers ¶ added in v1.25.0
RemovePodFinalizers removes pod finalizers for the pods
func RemoveTaintOffNode ¶ added in v1.19.0
RemoveTaintOffNode removes a specific taint from a node
func RunPausePod ¶ added in v1.24.10
RunPausePod creates a pod with "Pause" image and the given config and waits until it is scheduled. It returns its pointer and error status.
func RunPodWithContainers ¶ added in v1.24.10
RunPodWithContainers creates a pod with given config and containers and waits until it is scheduled. It returns its pointer and error status.
func SyncInformerFactory ¶ added in v1.19.0
func SyncInformerFactory(testCtx *TestContext)
SyncInformerFactory starts informer and waits for caches to be synced
func UpdateNode ¶ added in v1.24.10
func UpdateNodeStatus ¶ added in v1.18.0
UpdateNodeStatus updates the status of node.
func WaitCachedPodsStable ¶ added in v1.24.10
func WaitCachedPodsStable(testCtx *TestContext, pods []*v1.Pod) error
WaitCachedPodsStable waits until scheduler cache has the given pods.
func WaitForNodeTaints ¶ added in v1.18.0
WaitForNodeTaints waits for a node to have the target taints and returns an error if it does not have taints within the given timeout.
func WaitForNodesInCache ¶ added in v1.24.10
WaitForNodesInCache ensures at least <nodeCount> nodes are present in scheduler cache within 30 seconds; otherwise returns false.
func WaitForPDBsStable ¶ added in v1.24.10
func WaitForPDBsStable(testCtx *TestContext, pdbs []*policy.PodDisruptionBudget, pdbPodNum []int32) error
WaitForPDBsStable waits for PDBs to have "CurrentHealthy" status equal to the expected values.
func WaitForPodSchedulingGated ¶ added in v1.26.0
WaitForPodSchedulingGated waits for a pod to be in scheduling gated state and returns an error if it does not fall into this state within the given timeout.
func WaitForPodToSchedule ¶ added in v1.18.0
WaitForPodToSchedule waits for a pod to get scheduled and returns an error if it does not get scheduled within the timeout duration (30 seconds).
func WaitForPodToScheduleWithTimeout ¶ added in v1.18.0
func WaitForPodToScheduleWithTimeout(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error
WaitForPodToScheduleWithTimeout waits for a pod to get scheduled and returns an error if it does not scheduled within the given timeout.
func WaitForPodUnschedulable ¶ added in v1.24.10
WaitForPodUnschedulable waits for a pod to fail scheduling and returns an error if it does not become unschedulable within the timeout duration (30 seconds).
func WaitForPodUnschedulableWithTimeout ¶ added in v1.24.10
func WaitForPodUnschedulableWithTimeout(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error
WaitForPodUnschedulableWithTimeout waits for a pod to fail scheduling and returns an error if it does not become unschedulable within the given timeout.
func WaitForReflection ¶ added in v1.24.10
func WaitForReflection(t *testing.T, nodeLister corelisters.NodeLister, key string, passFunc func(n interface{}) bool) error
WaitForReflection waits till the passFunc confirms that the object it expects to see is in the store. Used to observe reflected events.
Types ¶
type PausePodConfig ¶ added in v1.24.10
type PausePodConfig struct { Name string Namespace string Affinity *v1.Affinity Annotations, Labels, NodeSelector map[string]string Resources *v1.ResourceRequirements Tolerations []v1.Toleration NodeName string SchedulerName string Priority *int32 PreemptionPolicy *v1.PreemptionPolicy PriorityClassName string Volumes []v1.Volume }
type PodWithContainersConfig ¶ added in v1.24.10
type ShutdownFunc ¶
type ShutdownFunc func()
ShutdownFunc represents the function handle to be called, typically in a defer handler, to shutdown a running module
func StartFakePVController ¶ added in v1.18.0
func StartFakePVController(clientSet clientset.Interface) ShutdownFunc
StartFakePVController is a simplified pv controller logic that sets PVC VolumeName and annotation for each PV binding. TODO(mborsz): Use a real PV controller here.
func StartScheduler ¶
func StartScheduler(clientSet clientset.Interface, kubeConfig *restclient.Config, cfg *kubeschedulerconfig.KubeSchedulerConfiguration) (*scheduler.Scheduler, coreinformers.PodInformer, ShutdownFunc)
StartScheduler configures and starts a scheduler given a handle to the clientSet interface and event broadcaster. It returns the running scheduler, podInformer and the shutdown function to stop it.
type TestContext ¶ added in v1.18.0
type TestContext struct { CloseFn framework.TearDownFunc NS *v1.Namespace ClientSet clientset.Interface KubeConfig *restclient.Config InformerFactory informers.SharedInformerFactory DynInformerFactory dynamicinformer.DynamicSharedInformerFactory Scheduler *scheduler.Scheduler Ctx context.Context CancelFn context.CancelFunc }
TestContext store necessary context info
func InitTestAPIServer ¶ added in v1.22.0
InitTestAPIServer initializes a test environment and creates an API server with default configuration.
func InitTestDisablePreemption ¶ added in v1.24.10
func InitTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext
InitTestDisablePreemption initializes a test environment and creates API server and scheduler with default configuration but with pod preemption disabled.
func InitTestScheduler ¶ added in v1.18.0
func InitTestScheduler( t *testing.T, testCtx *TestContext, ) *TestContext
InitTestScheduler initializes a test environment and creates a scheduler with default configuration.
func InitTestSchedulerWithNS ¶ added in v1.24.10
InitTestSchedulerWithNS initializes a test environment and creates API server and scheduler with default configuration.
func InitTestSchedulerWithOptions ¶ added in v1.18.0
func InitTestSchedulerWithOptions( t *testing.T, testCtx *TestContext, resyncPeriod time.Duration, opts ...scheduler.Option, ) *TestContext
InitTestSchedulerWithOptions initializes a test environment and creates a scheduler with default configuration and other options.