testing

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeNodesAndPods

func MakeNodesAndPods(pod *v1.Pod, existingPodsNum, allNodesNum, filteredNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node, filteredNodes []*v1.Node)

MakeNodesAndPods 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 "lableSelector.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.

Types

type FakeControllerLister

type FakeControllerLister []*v1.ReplicationController

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

func (FakeControllerLister) GetPodControllers

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

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

type FakeNodeLister

type FakeNodeLister []*v1.Node

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

func (FakeNodeLister) ListNodes

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

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

type FakePDBLister

type FakePDBLister []*policy.PodDisruptionBudget

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

func (FakePDBLister) List

List returns a list of PodDisruptionBudgets.

type FakePersistentVolumeClaimLister

type FakePersistentVolumeClaimLister []*v1.PersistentVolumeClaim

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

func (FakePersistentVolumeClaimLister) List

List returns not implemented error.

func (FakePersistentVolumeClaimLister) PersistentVolumeClaims

PersistentVolumeClaims returns a FakePersistentVolumeClaimLister object.

type FakePodLister

type FakePodLister []*v1.Pod

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

func (FakePodLister) FilteredList

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

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

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

type FakeReplicaSetLister

type FakeReplicaSetLister []*apps.ReplicaSet

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

func (FakeReplicaSetLister) GetPodReplicaSets

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

type FakeServiceLister []*v1.Service

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

func (FakeServiceLister) GetPodServices

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

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

type FakeStatefulSetLister

type FakeStatefulSetLister []*apps.StatefulSet

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

func (FakeStatefulSetLister) GetPodStatefulSets

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

type LabelSelectorWrapper struct{ metav1.LabelSelector }

LabelSelectorWrapper wraps a LabelSelector inside.

func MakeLabelSelector

func MakeLabelSelector() *LabelSelectorWrapper

MakeLabelSelector creates a LabelSelector wrapper.

func (*LabelSelectorWrapper) Exists

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

func (*LabelSelectorWrapper) In

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

func (*LabelSelectorWrapper) Label

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

func (*LabelSelectorWrapper) NotExist

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

func (*LabelSelectorWrapper) NotIn

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

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

func (*LabelSelectorWrapper) Obj

Obj returns the inner LabelSelector.

type NodeSelectorWrapper

type NodeSelectorWrapper struct{ v1.NodeSelector }

NodeSelectorWrapper wraps a NodeSelector inside.

func MakeNodeSelector

func MakeNodeSelector() *NodeSelectorWrapper

MakeNodeSelector creates a NodeSelector wrapper.

func (*NodeSelectorWrapper) In

In injects a matchExpression (with an operator IN) as a selectorTerm to the inner nodeSelector. NOTE: appended selecterTerms are ORed.

func (*NodeSelectorWrapper) NotIn

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

Obj returns the inner NodeSelector.

type NodeWrapper

type NodeWrapper struct{ v1.Node }

NodeWrapper wraps a Node inside.

func MakeNode

func MakeNode() *NodeWrapper

MakeNode creates a Node wrapper.

func (*NodeWrapper) Label

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

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

func (*NodeWrapper) Name

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

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

func (*NodeWrapper) Obj

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

Obj returns the inner Node.

type PodWrapper

type PodWrapper struct{ v1.Pod }

PodWrapper wraps a Pod inside.

func MakePod

func MakePod() *PodWrapper

MakePod creates a Pod wrapper.

func (*PodWrapper) Container

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

Container appends a container into PodSpec of the inner pod.

func (*PodWrapper) Label

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

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

func (*PodWrapper) Name

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

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

func (*PodWrapper) Namespace

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

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

func (*PodWrapper) Node

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

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

func (*PodWrapper) NodeAffinityIn

func (p *PodWrapper) NodeAffinityIn(key string, vals []string) *PodWrapper

NodeAffinityIn creates a HARD node affinity (with the operator In) and injects into the innner pod.

func (*PodWrapper) NodeAffinityNotIn

func (p *PodWrapper) NodeAffinityNotIn(key string, vals []string) *PodWrapper

NodeAffinityNotIn creates a HARD node affinity (with the operator NotIn) and injects into the innner pod.

func (*PodWrapper) NodeSelector

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

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

func (*PodWrapper) Obj

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

Obj returns the inner Pod.

func (*PodWrapper) Priority

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

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

func (*PodWrapper) SpreadConstraint

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

func (p *PodWrapper) ZeroTerminationGracePeriod() *PodWrapper

ZeroTerminationGracePeriod sets the TerminationGracePeriodSeconds of the inner pod to zero.

Jump to

Keyboard shortcuts

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