kubernetes: k8s.io/kubernetes/pkg/scheduler/testing Index | Files

package testing

import "k8s.io/kubernetes/pkg/scheduler/testing"

Index

Package Files

fake_lister.go workload_prep.go wrappers.go

func MakeNodesAndPods Uses

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 Uses

func MakeNodesAndPodsForEvenPodsSpread(pod *v1.Pod, 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: - If `pod` has "node" as a topologyKey, each generated node is applied with a unique label: "node: node<i>". - If `pod` has "zone" as a topologyKey, each generated node is applied with a rotating label: "zone: zone[0-9]". - Depending on "labelSelector.MatchExpressions[0].Key" the `pod` has in each topologySpreadConstraint,

each generated pod will be applied with label "key1", "key1,key2", ..., "key1,key2,...,keyN" in a rotating manner.

func MakeNodesAndPodsForPodAffinity Uses

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.

type FakeControllerLister Uses

type FakeControllerLister []*v1.ReplicationController

FakeControllerLister implements ControllerLister on []v1.ReplicationController for test purposes.

func (FakeControllerLister) GetPodControllers Uses

func (f FakeControllerLister) GetPodControllers(pod *v1.Pod) (controllers []*v1.ReplicationController, err error)

GetPodControllers gets the ReplicationControllers that have the selector that match the labels on the given pod

func (FakeControllerLister) List Uses

func (f FakeControllerLister) List(labels.Selector) ([]*v1.ReplicationController, error)

List returns []v1.ReplicationController, the list of all ReplicationControllers.

type FakeNodeLister Uses

type FakeNodeLister []*v1.Node

FakeNodeLister implements NodeLister on a []string for test purposes.

func (FakeNodeLister) ListNodes Uses

func (f FakeNodeLister) ListNodes() []*v1.Node

ListNodes returns nodes as a []*v1.Node.

type FakePDBLister Uses

type FakePDBLister []*policy.PodDisruptionBudget

FakePDBLister implements PDBLister on a slice of PodDisruptionBudgets for test purposes.

func (FakePDBLister) List Uses

func (f FakePDBLister) List(labels.Selector) ([]*policy.PodDisruptionBudget, error)

List returns a list of PodDisruptionBudgets.

type FakePersistentVolumeClaimLister Uses

type FakePersistentVolumeClaimLister []*v1.PersistentVolumeClaim

FakePersistentVolumeClaimLister implements PersistentVolumeClaimLister on []*v1.PersistentVolumeClaim for test purposes.

func (FakePersistentVolumeClaimLister) List Uses

func (f FakePersistentVolumeClaimLister) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error)

List returns not implemented error.

func (FakePersistentVolumeClaimLister) PersistentVolumeClaims Uses

func (f FakePersistentVolumeClaimLister) PersistentVolumeClaims(namespace string) corelisters.PersistentVolumeClaimNamespaceLister

PersistentVolumeClaims returns a FakePersistentVolumeClaimLister object.

type FakePodLister Uses

type FakePodLister []*v1.Pod

FakePodLister implements PodLister on an []v1.Pods for test purposes.

func (FakePodLister) FilteredList Uses

func (f FakePodLister) FilteredList(podFilter algorithm.PodFilter, s labels.Selector) (selected []*v1.Pod, err error)

FilteredList returns pods matching a pod filter and a label selector.

func (FakePodLister) List Uses

func (f FakePodLister) List(s labels.Selector) (selected []*v1.Pod, err error)

List returns []*v1.Pod matching a query.

type FakeReplicaSetLister Uses

type FakeReplicaSetLister []*apps.ReplicaSet

FakeReplicaSetLister implements ControllerLister on []extensions.ReplicaSet for test purposes.

func (FakeReplicaSetLister) GetPodReplicaSets Uses

func (f FakeReplicaSetLister) GetPodReplicaSets(pod *v1.Pod) (rss []*apps.ReplicaSet, err error)

GetPodReplicaSets gets the ReplicaSets that have the selector that match the labels on the given pod

type FakeServiceLister Uses

type FakeServiceLister []*v1.Service

FakeServiceLister implements ServiceLister on []v1.Service for test purposes.

func (FakeServiceLister) GetPodServices Uses

func (f FakeServiceLister) GetPodServices(pod *v1.Pod) (services []*v1.Service, err error)

GetPodServices gets the services that have the selector that match the labels on the given pod.

func (FakeServiceLister) List Uses

func (f FakeServiceLister) List(labels.Selector) ([]*v1.Service, error)

List returns v1.ServiceList, the list of all services.

type FakeStatefulSetLister Uses

type FakeStatefulSetLister []*apps.StatefulSet

FakeStatefulSetLister implements ControllerLister on []apps.StatefulSet for testing purposes.

func (FakeStatefulSetLister) GetPodStatefulSets Uses

func (f FakeStatefulSetLister) GetPodStatefulSets(pod *v1.Pod) (sss []*apps.StatefulSet, err error)

GetPodStatefulSets gets the StatefulSets that have the selector that match the labels on the given pod.

type LabelSelectorWrapper Uses

type LabelSelectorWrapper struct{ metav1.LabelSelector }

LabelSelectorWrapper wraps a LabelSelector inside.

func MakeLabelSelector Uses

func MakeLabelSelector() *LabelSelectorWrapper

MakeLabelSelector creates a LabelSelector wrapper.

func (*LabelSelectorWrapper) Exists Uses

func (s *LabelSelectorWrapper) Exists(k string) *LabelSelectorWrapper

Exists injects a matchExpression (with an operator Exists) to the inner labelSelector.

func (*LabelSelectorWrapper) In Uses

func (s *LabelSelectorWrapper) In(key string, vals []string) *LabelSelectorWrapper

In injects a matchExpression (with an operator In) to the inner labelSelector.

func (*LabelSelectorWrapper) Label Uses

func (s *LabelSelectorWrapper) Label(k, v string) *LabelSelectorWrapper

Label applies a {k,v} pair to the inner LabelSelector.

func (*LabelSelectorWrapper) NotExist Uses

func (s *LabelSelectorWrapper) NotExist(k string) *LabelSelectorWrapper

NotExist injects a matchExpression (with an operator NotExist) to the inner labelSelector.

func (*LabelSelectorWrapper) NotIn Uses

func (s *LabelSelectorWrapper) NotIn(key string, vals []string) *LabelSelectorWrapper

NotIn injects a matchExpression (with an operator NotIn) to the inner labelSelector.

func (*LabelSelectorWrapper) Obj Uses

func (s *LabelSelectorWrapper) Obj() *metav1.LabelSelector

Obj returns the inner LabelSelector.

type NodeSelectorWrapper Uses

type NodeSelectorWrapper struct{ v1.NodeSelector }

NodeSelectorWrapper wraps a NodeSelector inside.

func MakeNodeSelector Uses

func MakeNodeSelector() *NodeSelectorWrapper

MakeNodeSelector creates a NodeSelector wrapper.

func (*NodeSelectorWrapper) In Uses

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 (*NodeSelectorWrapper) NotIn Uses

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 (*NodeSelectorWrapper) Obj Uses

func (s *NodeSelectorWrapper) Obj() *v1.NodeSelector

Obj returns the inner NodeSelector.

type NodeWrapper Uses

type NodeWrapper struct{ v1.Node }

NodeWrapper wraps a Node inside.

func MakeNode Uses

func MakeNode() *NodeWrapper

MakeNode creates a Node wrapper.

func (*NodeWrapper) Label Uses

func (n *NodeWrapper) Label(k, v string) *NodeWrapper

Label applies a {k,v} label pair to the inner node.

func (*NodeWrapper) Name Uses

func (n *NodeWrapper) Name(s string) *NodeWrapper

Name sets `s` as the name of the inner pod.

func (*NodeWrapper) Obj Uses

func (n *NodeWrapper) Obj() *v1.Node

Obj returns the inner Node.

type PodAffinityKind Uses

type PodAffinityKind int

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
)

type PodWrapper Uses

type PodWrapper struct{ v1.Pod }

PodWrapper wraps a Pod inside.

func MakePod Uses

func MakePod() *PodWrapper

MakePod creates a Pod wrapper.

func (*PodWrapper) Container Uses

func (p *PodWrapper) Container(s string) *PodWrapper

Container appends a container into PodSpec of the inner pod.

func (*PodWrapper) Label Uses

func (p *PodWrapper) Label(k, v string) *PodWrapper

Label sets a {k,v} pair to the inner pod.

func (*PodWrapper) Name Uses

func (p *PodWrapper) Name(s string) *PodWrapper

Name sets `s` as the name of the inner pod.

func (*PodWrapper) Namespace Uses

func (p *PodWrapper) Namespace(s string) *PodWrapper

Namespace sets `s` as the namespace of the inner pod.

func (*PodWrapper) Node Uses

func (p *PodWrapper) Node(s string) *PodWrapper

Node sets `s` as the nodeName of the inner pod.

func (*PodWrapper) NodeAffinityIn Uses

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 (*PodWrapper) NodeAffinityNotIn Uses

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 (*PodWrapper) NodeSelector Uses

func (p *PodWrapper) NodeSelector(m map[string]string) *PodWrapper

NodeSelector sets `m` as the nodeSelector of the inner pod.

func (*PodWrapper) Obj Uses

func (p *PodWrapper) Obj() *v1.Pod

Obj returns the inner Pod.

func (*PodWrapper) PodAffinityExists Uses

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 (*PodWrapper) PodAntiAffinityExists Uses

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 (*PodWrapper) Priority Uses

func (p *PodWrapper) Priority(val int32) *PodWrapper

Priority sets a priority value into PodSpec of the inner pod.

func (*PodWrapper) SpreadConstraint Uses

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 (*PodWrapper) ZeroTerminationGracePeriod Uses

func (p *PodWrapper) ZeroTerminationGracePeriod() *PodWrapper

ZeroTerminationGracePeriod sets the TerminationGracePeriodSeconds of the inner pod to zero.

Package testing imports 8 packages (graph). Updated 2019-09-22. Refresh now. Tools for package owners.