import "k8s.io/kubernetes/pkg/scheduler/testing"
fake_extender.go fake_plugins.go framework_helpers.go workload_prep.go wrappers.go
const ErrReasonFake = "Nodes failed the fake plugin"
ErrReasonFake is a fake error message denotes the filter function errored.
ErrorPredicateExtender implements FitPredicate function to always return error.
ErrorPrioritizerExtender implements PriorityFunc function to always return error.
FalsePredicateExtender implements FitPredicate function to always return false.
func MakeNodesAndPods(existingPodsNum, allNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node)
MakeNodesAndPods serves as a testing helper to generate regular Nodes and Pods that don't use any advanced scheduling features.
func MakeNodesAndPodsForEvenPodsSpread(labels map[string]string, existingPodsNum, allNodesNum, filteredNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node, filteredNodes []*v1.Node)
MakeNodesAndPodsForEvenPodsSpread serves as a testing helper for EvenPodsSpread feature. It builds a fake cluster containing running Pods and Nodes. The size of Pods and Nodes are determined by input arguments. The specs of Pods and Nodes are generated with the following rules: - Each generated node is applied with a unique label: "node: node<i>". - Each generated node is applied with a rotating label: "zone: zone[0-9]". - Depending on the input labels, each generated pod will be applied with
label "key1", "key1,key2", ..., "key1,key2,...,keyN" in a rotating manner.
func MakeNodesAndPodsForPodAffinity(existingPodsNum, allNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node)
MakeNodesAndPodsForPodAffinity serves as a testing helper for Pod(Anti)Affinity feature. It builds a fake cluster containing running Pods and Nodes. For simplicity, the Nodes will be labelled with "region", "zone" and "node". Nodes[i] will be applied with: - "region": "region" + i%3 - "zone": "zone" + i%10 - "node": "node" + i The Pods will be applied with various combinations of PodAffinity and PodAntiAffinity terms.
func NewFakeFilterPlugin(failedNodeReturnCodeMap map[string]framework.Code) frameworkruntime.PluginFactory
NewFakeFilterPlugin initializes a fakeFilterPlugin and returns it.
func NewFakePermitPlugin(status *framework.Status, timeout time.Duration) frameworkruntime.PluginFactory
NewFakePermitPlugin initializes a fakePermitPlugin and returns it.
func NewFakePreBindPlugin(status *framework.Status) frameworkruntime.PluginFactory
NewFakePreBindPlugin initializes a fakePreBindPlugin and returns it.
func NewFakePreFilterPlugin(status *framework.Status) frameworkruntime.PluginFactory
NewFakePreFilterPlugin initializes a fakePreFilterPlugin and returns it.
func NewFakeReservePlugin(status *framework.Status) frameworkruntime.PluginFactory
NewFakeReservePlugin initializes a fakeReservePlugin and returns it.
NewFalseFilterPlugin initializes a FalseFilterPlugin and returns it.
NewFramework creates a Framework from the register functions and options.
NewMatchFilterPlugin initializes a MatchFilterPlugin and returns it.
func NewNode2PrioritizerPlugin() frameworkruntime.PluginFactory
NewNode2PrioritizerPlugin returns a factory function to build node2PrioritizerPlugin.
NewTrueFilterPlugin initializes a TrueFilterPlugin and returns it.
Node1PredicateExtender implements FitPredicate function to return true when the given node's name is "node1"; otherwise return false.
Node1PrioritizerExtender implements PriorityFunc function to give score 10 if the given node's name is "node1"; otherwise score 1.
Node2PredicateExtender implements FitPredicate function to return true when the given node's name is "node2"; otherwise return false.
Node2PrioritizerExtender implements PriorityFunc function to give score 10 if the given node's name is "node2"; otherwise score 1.
TruePredicateExtender implements FitPredicate function to always return true.
type FakeExtender struct { Predicates []FitPredicate Prioritizers []PriorityConfig Weight int64 NodeCacheCapable bool FilteredNodes []*v1.Node UnInterested bool Ignorable bool // Cached node information for fake extender CachedNodeNameToInfo map[string]*framework.NodeInfo }
FakeExtender is a data struct which implements the Extender interface.
func (f *FakeExtender) Bind(binding *v1.Binding) error
Bind implements the extender Bind function.
func (f *FakeExtender) Filter(pod *v1.Pod, nodes []*v1.Node) ([]*v1.Node, extenderv1.FailedNodesMap, error)
Filter implements the extender Filter function.
func (f *FakeExtender) IsBinder() bool
IsBinder returns true indicating the extender implements the Binder function.
func (f *FakeExtender) IsIgnorable() bool
IsIgnorable returns a bool value indicating whether internal errors can be ignored.
func (f *FakeExtender) IsInterested(pod *v1.Pod) bool
IsInterested returns a bool true indicating whether extender
func (f *FakeExtender) Name() string
Name returns name of the extender.
func (f *FakeExtender) Prioritize(pod *v1.Pod, nodes []*v1.Node) (*extenderv1.HostPriorityList, int64, error)
Prioritize implements the extender Prioritize function.
func (f *FakeExtender) ProcessPreemption( pod *v1.Pod, nodeNameToVictims map[string]*extenderv1.Victims, nodeInfos framework.NodeInfoLister, ) (map[string]*extenderv1.Victims, error)
ProcessPreemption implements the extender preempt function.
func (f *FakeExtender) SupportsPreemption() bool
SupportsPreemption returns true indicating the extender supports preemption.
type FakeFilterPlugin struct { NumFilterCalled int32 FailedNodeReturnCodeMap map[string]framework.Code }
FakeFilterPlugin is a test filter plugin to record how many times its Filter() function have been called, and it returns different 'Code' depending on its internal 'failedNodeReturnCodeMap'.
func (pl *FakeFilterPlugin) Filter(_ context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status
Filter invoked at the filter extension point.
func (pl *FakeFilterPlugin) Name() string
Name returns name of the plugin.
FakePermitPlugin is a test permit plugin.
func (pl *FakePermitPlugin) Name() string
Name returns name of the plugin.
func (pl *FakePermitPlugin) Permit(_ context.Context, _ *framework.CycleState, _ *v1.Pod, _ string) (*framework.Status, time.Duration)
Permit invoked at the Permit extension point.
FakePreBindPlugin is a test prebind plugin.
func (pl *FakePreBindPlugin) Name() string
Name returns name of the plugin.
func (pl *FakePreBindPlugin) PreBind(_ context.Context, _ *framework.CycleState, _ *v1.Pod, _ string) *framework.Status
PreBind invoked at the PreBind extension point.
FakePreFilterPlugin is a test filter plugin.
func (pl *FakePreFilterPlugin) Name() string
Name returns name of the plugin.
func (pl *FakePreFilterPlugin) PreFilter(_ context.Context, _ *framework.CycleState, pod *v1.Pod) *framework.Status
PreFilter invoked at the PreFilter extension point.
func (pl *FakePreFilterPlugin) PreFilterExtensions() framework.PreFilterExtensions
PreFilterExtensions no extensions implemented by this plugin.
FakeReservePlugin is a test reserve plugin.
func (pl *FakeReservePlugin) Name() string
Name returns name of the plugin.
func (pl *FakeReservePlugin) Reserve(_ context.Context, _ *framework.CycleState, _ *v1.Pod, _ string) *framework.Status
Reserve invoked at the Reserve extension point.
func (pl *FakeReservePlugin) Unreserve(_ context.Context, _ *framework.CycleState, _ *v1.Pod, _ string)
Unreserve invoked at the Unreserve extension point.
type FalseFilterPlugin struct{}
FalseFilterPlugin is a filter plugin which always return Unschedulable when Filter function is called.
func (pl *FalseFilterPlugin) Filter(_ context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status
Filter invoked at the filter extension point.
func (pl *FalseFilterPlugin) Name() string
Name returns name of the plugin.
FitPredicate is a function type which is used in fake extender.
type LabelSelectorWrapper struct{ metav1.LabelSelector }
LabelSelectorWrapper wraps a LabelSelector inside.
func MakeLabelSelector() *LabelSelectorWrapper
MakeLabelSelector creates a LabelSelector wrapper.
func (s *LabelSelectorWrapper) Exists(k string) *LabelSelectorWrapper
Exists injects a matchExpression (with an operator Exists) to the inner labelSelector.
func (s *LabelSelectorWrapper) In(key string, vals []string) *LabelSelectorWrapper
In injects a matchExpression (with an operator In) to the inner labelSelector.
func (s *LabelSelectorWrapper) Label(k, v string) *LabelSelectorWrapper
Label applies a {k,v} pair to the inner LabelSelector.
func (s *LabelSelectorWrapper) NotExist(k string) *LabelSelectorWrapper
NotExist injects a matchExpression (with an operator NotExist) to the inner labelSelector.
func (s *LabelSelectorWrapper) NotIn(key string, vals []string) *LabelSelectorWrapper
NotIn injects a matchExpression (with an operator NotIn) to the inner labelSelector.
func (s *LabelSelectorWrapper) Obj() *metav1.LabelSelector
Obj returns the inner LabelSelector.
type MatchFilterPlugin struct{}
MatchFilterPlugin is a filter plugin which return Success when the evaluated pod and node have the same name; otherwise return Unschedulable.
func (pl *MatchFilterPlugin) Filter(_ context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status
Filter invoked at the filter extension point.
func (pl *MatchFilterPlugin) Name() string
Name returns name of the plugin.
type NodeSelectorWrapper struct{ v1.NodeSelector }
NodeSelectorWrapper wraps a NodeSelector inside.
func MakeNodeSelector() *NodeSelectorWrapper
MakeNodeSelector creates a NodeSelector wrapper.
func (s *NodeSelectorWrapper) In(key string, vals []string) *NodeSelectorWrapper
In injects a matchExpression (with an operator IN) as a selectorTerm to the inner nodeSelector. NOTE: appended selecterTerms are ORed.
func (s *NodeSelectorWrapper) NotIn(key string, vals []string) *NodeSelectorWrapper
NotIn injects a matchExpression (with an operator NotIn) as a selectorTerm to the inner nodeSelector.
func (s *NodeSelectorWrapper) Obj() *v1.NodeSelector
Obj returns the inner NodeSelector.
NodeWrapper wraps a Node inside.
func MakeNode() *NodeWrapper
MakeNode creates a Node wrapper.
func (n *NodeWrapper) Capacity(resources map[v1.ResourceName]string) *NodeWrapper
Capacity sets the capacity and the allocatable resources of the inner node. Each entry in `resources` corresponds to a resource name and its quantity. By default, the capacity and allocatable number of pods are set to 32.
func (n *NodeWrapper) Images(images map[string]int64) *NodeWrapper
Images sets the images of the inner node. Each entry in `images` corresponds to an image name and its size in bytes.
func (n *NodeWrapper) Label(k, v string) *NodeWrapper
Label applies a {k,v} label pair to the inner node.
func (n *NodeWrapper) Name(s string) *NodeWrapper
Name sets `s` as the name of the inner pod.
func (n *NodeWrapper) Obj() *v1.Node
Obj returns the inner Node.
func (n *NodeWrapper) UID(s string) *NodeWrapper
UID sets `s` as the UID of the inner pod.
PodAffinityKind represents different kinds of PodAffinity.
const ( // NilPodAffinity is a no-op which doesn't apply any PodAffinity. NilPodAffinity PodAffinityKind = iota // PodAffinityWithRequiredReq applies a HARD requirement to pod.spec.affinity.PodAffinity. PodAffinityWithRequiredReq // PodAffinityWithPreferredReq applies a SOFT requirement to pod.spec.affinity.PodAffinity. PodAffinityWithPreferredReq // PodAffinityWithRequiredPreferredReq applies HARD and SOFT requirements to pod.spec.affinity.PodAffinity. PodAffinityWithRequiredPreferredReq // PodAntiAffinityWithRequiredReq applies a HARD requirement to pod.spec.affinity.PodAntiAffinity. PodAntiAffinityWithRequiredReq // PodAntiAffinityWithPreferredReq applies a SOFT requirement to pod.spec.affinity.PodAntiAffinity. PodAntiAffinityWithPreferredReq // PodAntiAffinityWithRequiredPreferredReq applies HARD and SOFT requirements to pod.spec.affinity.PodAntiAffinity. PodAntiAffinityWithRequiredPreferredReq )
PodWrapper wraps a Pod inside.
func MakePod() *PodWrapper
MakePod creates a Pod wrapper.
func (p *PodWrapper) Container(s string) *PodWrapper
Container appends a container into PodSpec of the inner pod.
func (p *PodWrapper) Label(k, v string) *PodWrapper
Label sets a {k,v} pair to the inner pod.
func (p *PodWrapper) Name(s string) *PodWrapper
Name sets `s` as the name of the inner pod.
func (p *PodWrapper) Namespace(s string) *PodWrapper
Namespace sets `s` as the namespace of the inner pod.
func (p *PodWrapper) Node(s string) *PodWrapper
Node sets `s` as the nodeName of the inner pod.
func (p *PodWrapper) NodeAffinityIn(key string, vals []string) *PodWrapper
NodeAffinityIn creates a HARD node affinity (with the operator In) and injects into the inner pod.
func (p *PodWrapper) NodeAffinityNotIn(key string, vals []string) *PodWrapper
NodeAffinityNotIn creates a HARD node affinity (with the operator NotIn) and injects into the inner pod.
func (p *PodWrapper) NodeSelector(m map[string]string) *PodWrapper
NodeSelector sets `m` as the nodeSelector of the inner pod.
func (p *PodWrapper) NominatedNodeName(n string) *PodWrapper
NominatedNodeName sets `n` as the .Status.NominatedNodeName of the inner pod.
func (p *PodWrapper) Obj() *v1.Pod
Obj returns the inner Pod.
func (p *PodWrapper) PodAffinityExists(labelKey, topologyKey string, kind PodAffinityKind) *PodWrapper
PodAffinityExists creates an PodAffinity with the operator "Exists" and injects into the inner pod.
func (p *PodWrapper) PodAntiAffinityExists(labelKey, topologyKey string, kind PodAffinityKind) *PodWrapper
PodAntiAffinityExists creates an PodAntiAffinity with the operator "Exists" and injects into the inner pod.
func (p *PodWrapper) PreemptionPolicy(policy v1.PreemptionPolicy) *PodWrapper
PreemptionPolicy sets the give preemption policy to the inner pod.
func (p *PodWrapper) Priority(val int32) *PodWrapper
Priority sets a priority value into PodSpec of the inner pod.
func (p *PodWrapper) Req(resMap map[v1.ResourceName]string) *PodWrapper
Req adds a new container to the inner pod with given resource map.
func (p *PodWrapper) SchedulerName(s string) *PodWrapper
SchedulerName sets `s` as the scheduler name of the inner pod.
func (p *PodWrapper) SpreadConstraint(maxSkew int, tpKey string, mode v1.UnsatisfiableConstraintAction, selector *metav1.LabelSelector) *PodWrapper
SpreadConstraint constructs a TopologySpreadConstraint object and injects into the inner pod.
func (p *PodWrapper) StartTime(t metav1.Time) *PodWrapper
StartTime sets `t` as .status.startTime for the inner pod.
func (p *PodWrapper) Terminating() *PodWrapper
Terminating sets the inner pod's deletionTimestamp to current timestamp.
func (p *PodWrapper) UID(s string) *PodWrapper
UID sets `s` as the UID of the inner pod.
func (p *PodWrapper) ZeroTerminationGracePeriod() *PodWrapper
ZeroTerminationGracePeriod sets the TerminationGracePeriodSeconds of the inner pod to zero.
type PriorityConfig struct { Function PriorityFunc Weight int64 }
PriorityConfig is used in fake extender to perform Prioritize function.
PriorityFunc is a function type which is used in fake extender.
type RegisterPluginFunc func(reg *runtime.Registry, plugins *schedulerapi.Plugins, pluginConfigs []schedulerapi.PluginConfig)
RegisterPluginFunc is a function signature used in method RegisterFilterPlugin() to register a Filter Plugin to a given registry.
func RegisterBindPlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterBindPlugin returns a function to register a Bind Plugin to a given registry.
func RegisterFilterPlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterFilterPlugin returns a function to register a Filter Plugin to a given registry.
func RegisterPermitPlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterPermitPlugin returns a function to register a Permit Plugin to a given registry.
func RegisterPluginAsExtensions(pluginName string, pluginNewFunc runtime.PluginFactory, extensions ...string) RegisterPluginFunc
RegisterPluginAsExtensions returns a function to register a Plugin as given extensionPoints to a given registry.
func RegisterPluginAsExtensionsWithWeight(pluginName string, weight int32, pluginNewFunc runtime.PluginFactory, extensions ...string) RegisterPluginFunc
RegisterPluginAsExtensionsWithWeight returns a function to register a Plugin as given extensionPoints with weight to a given registry.
func RegisterPreBindPlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterPreBindPlugin returns a function to register a PreBind Plugin to a given registry.
func RegisterPreFilterPlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterPreFilterPlugin returns a function to register a PreFilter Plugin to a given registry.
func RegisterPreScorePlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterPreScorePlugin returns a function to register a Score Plugin to a given registry.
func RegisterQueueSortPlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterQueueSortPlugin returns a function to register a QueueSort Plugin to a given registry.
func RegisterReservePlugin(pluginName string, pluginNewFunc runtime.PluginFactory) RegisterPluginFunc
RegisterReservePlugin returns a function to register a Reserve Plugin to a given registry.
func RegisterScorePlugin(pluginName string, pluginNewFunc runtime.PluginFactory, weight int32) RegisterPluginFunc
RegisterScorePlugin returns a function to register a Score Plugin to a given registry.
type TrueFilterPlugin struct{}
TrueFilterPlugin is a filter plugin which always return Success when Filter function is called.
func (pl *TrueFilterPlugin) Filter(_ context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status
Filter invoked at the filter extension point.
func (pl *TrueFilterPlugin) Name() string
Name returns name of the plugin.
Package testing imports 16 packages (graph) and is imported by 2 packages. Updated 2020-11-25. Refresh now. Tools for package owners.