test

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const NodePollInterval = 10 * time.Millisecond

Variables

View Source
var AlwaysReady = func() bool { return true }

Functions

func FakeNodeInformer

func FakeNodeInformer(fakeNodeHandler *FakeNodeHandler) coreinformers.NodeInformer

FakeNodeInformer creates a fakeNodeInformer using the provided fakeNodeHandler.

func NewNode

func NewNode(name string) *v1.Node

NewNode is a helper function for creating Nodes for testing.

func WaitForUpdatedNodeWithTimeout

func WaitForUpdatedNodeWithTimeout(nodeHandler *FakeNodeHandler, number int, timeout time.Duration) error

Types

type FakeLegacyHandler

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

FakeLegacyHandler is a fake implementation of CoreV1Interface.

func (*FakeLegacyHandler) Nodes

Nodes return fake NodeInterfaces.

type FakeNodeHandler

type FakeNodeHandler struct {
	*fake.Clientset

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

	// 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) Apply

Apply applies a NodeApplyConfiguration to a Node in the fake store.

func (*FakeNodeHandler) ApplyStatus

ApplyStatus applies a status of a Node in the fake store.

func (*FakeNodeHandler) Core

Core returns fake CoreInterface.

func (*FakeNodeHandler) CoreV1

CoreV1 returns fake CoreV1Interface.

func (*FakeNodeHandler) Create

func (m *FakeNodeHandler) Create(_ context.Context, node *v1.Node, _ metav1.CreateOptions) (*v1.Node, error)

Create adds a new Node to the fake store.

func (*FakeNodeHandler) Delete

Delete deletes a Node from the fake store.

func (*FakeNodeHandler) DeleteCollection

DeleteCollection deletes a collection of Nodes from the fake store.

func (*FakeNodeHandler) Get

Get returns a Node from the fake store.

func (*FakeNodeHandler) GetUpdatedNodesCopy

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

GetUpdatedNodesCopy returns a slice of Nodes with updates applied.

func (*FakeNodeHandler) List

List returns a list of Nodes from the fake store.

func (*FakeNodeHandler) Patch

func (m *FakeNodeHandler) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, _ metav1.PatchOptions, _ ...string) (*v1.Node, error)

Patch patches a Node in the fake store.

func (*FakeNodeHandler) PatchStatus

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

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

func (*FakeNodeHandler) Update

func (m *FakeNodeHandler) Update(_ context.Context, node *v1.Node, _ metav1.UpdateOptions) (*v1.Node, error)

Update updates a Node in the fake store.

func (*FakeNodeHandler) UpdateStatus

func (m *FakeNodeHandler) UpdateStatus(_ context.Context, node *v1.Node, _ metav1.UpdateOptions) (*v1.Node, error)

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

func (*FakeNodeHandler) Watch

Watch watches Nodes in a fake store.

Jump to

Keyboard shortcuts

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