kubernetes: k8s.io/kubernetes/pkg/controller/testutil Index | Files

package testutil

import "k8s.io/kubernetes/pkg/controller/testutil"

Index

Package Files

test_utils.go

func CreateZoneID Uses

func CreateZoneID(region, zone string) string

CreateZoneID returns a single zoneID for a given region and zone.

func GetKey Uses

func GetKey(obj interface{}, t *testing.T) string

GetKey is a helper function used by controllers unit tests to get the key for a given kubernetes resource.

func GetZones Uses

func GetZones(nodeHandler *FakeNodeHandler) []string

GetZones returns list of zones for all Nodes stored in FakeNodeHandler

func NewNode Uses

func NewNode(name string) *v1.Node

NewNode is a helper function for creating Nodes for testing.

func NewPod Uses

func NewPod(name, host string) *v1.Pod

NewPod is a helper function for creating Pods for testing.

type FakeLegacyHandler Uses

type FakeLegacyHandler struct {
    v1core.CoreV1Interface
    // contains filtered or unexported fields
}

FakeLegacyHandler is a fake implementation of CoreV1Interface.

func (*FakeLegacyHandler) Nodes Uses

func (m *FakeLegacyHandler) Nodes() v1core.NodeInterface

Nodes return fake NodeInterfaces.

type FakeNodeHandler Uses

type FakeNodeHandler struct {
    *fake.Clientset

    // Input: Hooks determine if request is valid or not
    CreateHook func(*FakeNodeHandler, *v1.Node) bool
    Existing   []*v1.Node

    // Output
    CreatedNodes        []*v1.Node
    DeletedNodes        []*v1.Node
    UpdatedNodes        []*v1.Node
    UpdatedNodeStatuses []*v1.Node
    RequestCount        int

    DeleteWaitChan chan struct{}
    PatchWaitChan  chan struct{}
    // contains filtered or unexported fields
}

FakeNodeHandler is a fake implementation of NodesInterface and NodeInterface. It allows test cases to have fine-grained control over mock behaviors. We also need PodsInterface and PodInterface to test list & delete pods, which is implemented in the embedded client.Fake field.

func (*FakeNodeHandler) Core Uses

func (m *FakeNodeHandler) Core() v1core.CoreV1Interface

Core returns fake CoreInterface.

func (*FakeNodeHandler) CoreV1 Uses

func (m *FakeNodeHandler) CoreV1() v1core.CoreV1Interface

CoreV1 returns fake CoreV1Interface

func (*FakeNodeHandler) Create Uses

func (m *FakeNodeHandler) Create(node *v1.Node) (*v1.Node, error)

Create adds a new Node to the fake store.

func (*FakeNodeHandler) Delete Uses

func (m *FakeNodeHandler) Delete(id string, opt *metav1.DeleteOptions) error

Delete deletes a Node from the fake store.

func (*FakeNodeHandler) DeleteCollection Uses

func (m *FakeNodeHandler) DeleteCollection(opt *metav1.DeleteOptions, listOpts metav1.ListOptions) error

DeleteCollection deletes a collection of Nodes from the fake store.

func (*FakeNodeHandler) Get Uses

func (m *FakeNodeHandler) Get(name string, opts metav1.GetOptions) (*v1.Node, error)

Get returns a Node from the fake store.

func (*FakeNodeHandler) GetUpdatedNodesCopy Uses

func (m *FakeNodeHandler) GetUpdatedNodesCopy() []*v1.Node

GetUpdatedNodesCopy returns a slice of Nodes with updates applied.

func (*FakeNodeHandler) List Uses

func (m *FakeNodeHandler) List(opts metav1.ListOptions) (*v1.NodeList, error)

List returns a list of Nodes from the fake store.

func (*FakeNodeHandler) Patch Uses

func (m *FakeNodeHandler) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*v1.Node, error)

Patch patches a Node in the fake store.

func (*FakeNodeHandler) PatchStatus Uses

func (m *FakeNodeHandler) PatchStatus(nodeName string, data []byte) (*v1.Node, error)

PatchStatus patches a status of a Node in the fake store.

func (*FakeNodeHandler) Update Uses

func (m *FakeNodeHandler) Update(node *v1.Node) (*v1.Node, error)

Update updates a Node in the fake store.

func (*FakeNodeHandler) UpdateStatus Uses

func (m *FakeNodeHandler) UpdateStatus(node *v1.Node) (*v1.Node, error)

UpdateStatus updates a status of a Node in the fake store.

func (*FakeNodeHandler) Watch Uses

func (m *FakeNodeHandler) Watch(opts metav1.ListOptions) (watch.Interface, error)

Watch watches Nodes in a fake store.

type FakeRecorder Uses

type FakeRecorder struct {
    sync.Mutex

    Events []*v1.Event
    // contains filtered or unexported fields
}

FakeRecorder is used as a fake during testing.

func NewFakeRecorder Uses

func NewFakeRecorder() *FakeRecorder

NewFakeRecorder returns a pointer to a newly constructed FakeRecorder.

func (*FakeRecorder) AnnotatedEventf Uses

func (f *FakeRecorder) AnnotatedEventf(obj runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})

AnnotatedEventf emits a fake formatted event to the fake recorder

func (*FakeRecorder) Event Uses

func (f *FakeRecorder) Event(obj runtime.Object, eventtype, reason, message string)

Event emits a fake event to the fake recorder

func (*FakeRecorder) Eventf Uses

func (f *FakeRecorder) Eventf(obj runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf emits a fake formatted event to the fake recorder

func (*FakeRecorder) PastEventf Uses

func (f *FakeRecorder) PastEventf(obj runtime.Object, timestamp metav1.Time, eventtype, reason, messageFmt string, args ...interface{})

PastEventf is a no-op

Package testutil imports 26 packages (graph). Updated 2019-07-26. Refresh now. Tools for package owners.