mock

package
v1.11.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenTestEndpointsPairs

func GenTestEndpointsPairs() (k8s.Endpoints, slim_corev1.Endpoints, metallbspr.Endpoints)

GenTestEndpointsPair generates a k8s.Endpoints and a hardcoded conversion to a metallbspr.Endpoints, along with a hardoced conversion to slim_corev1.Endpoints.

Since the conversion are hardcoded, the returned types are useful for testing any code which transforms one data structure to the other.

func GenTestNodeAndAdvertisements

func GenTestNodeAndAdvertisements() (v1.Node, []*metallbbgp.Advertisement)

GenTestNodeAndAdvertisements generates a v1.Node with its ObjectMeta and PodCidr(s) fields hardcoded along with the MetalLB Advertisements that would be announced by this node.

The returned Node's name is set to nodetypes.GetName() to simulate it being the node the Cilium agent is running on.

See definition for details.

func GenTestServicePairs

func GenTestServicePairs() (slim_corev1.Service, v1.Service, metallbspr.Service, k8s.ServiceID)

GenTestServicePairs generates a slim_corev1.Service and a hardcoded conversion to a metallbspr.Service and k8s v1.Service, along with a hardcoded conversion to a k8s.ServiceID.

Since the conversion is hardcoded, the returned types are useful for testing any code which transforms one data structure to the another.

See definition for details.

Types

type MockEndpointGetter

type MockEndpointGetter struct {
	GetEndpointsOfService_ func(svcID k8s.ServiceID) *k8s.Endpoints
}

MockEndpointGetter implements the method set for obtaining th endpoints of a Service.

func (*MockEndpointGetter) GetEndpointsOfService

func (m *MockEndpointGetter) GetEndpointsOfService(svcID k8s.ServiceID) *k8s.Endpoints

type MockIndexer

type MockIndexer struct {
	GetByKey_ func(key string) (item interface{}, exists bool, err error)
	ListKeys_ func() []string
}

MockIndexer implements the cache.Store interface from the k8s.io/client-go/cache package

The BGP package only utilizes two methods from this interface thus our mock is terse.

func (*MockIndexer) Add

func (m *MockIndexer) Add(obj interface{}) error

func (*MockIndexer) Delete

func (m *MockIndexer) Delete(obj interface{}) error

func (*MockIndexer) Get

func (m *MockIndexer) Get(obj interface{}) (item interface{}, exists bool, err error)

func (*MockIndexer) GetByKey

func (m *MockIndexer) GetByKey(key string) (item interface{}, exists bool, err error)

func (*MockIndexer) List

func (m *MockIndexer) List() []interface{}

func (*MockIndexer) ListKeys

func (m *MockIndexer) ListKeys() []string

func (*MockIndexer) Replace

func (m *MockIndexer) Replace([]interface{}, string) error

func (*MockIndexer) Resync

func (m *MockIndexer) Resync() error

func (*MockIndexer) Update

func (m *MockIndexer) Update(obj interface{}) error

type MockMetalLBController

type MockMetalLBController struct {
	SetBalancer_ func(name string, srvRo *v1.Service, eps metallbk8s.EpsOrSlices) types.SyncState
	MarkSynced_  func()
}

MockMetalLBController implements the manager.Controller interface by delegating to a set of functions defined during test.

func (*MockMetalLBController) MarkSynced

func (m *MockMetalLBController) MarkSynced()

func (*MockMetalLBController) SetBalancer

func (m *MockMetalLBController) SetBalancer(name string, srvRo *v1.Service, eps metallbk8s.EpsOrSlices) types.SyncState

type MockMetalLBSpeaker

type MockMetalLBSpeaker struct {
	SetService_    func(name string, svc *metallbspr.Service, eps *metallbspr.Endpoints) types.SyncState
	SetNodeLabels_ func(labels map[string]string) types.SyncState
	PeerSession_   func() []metallbspr.Session
}

MockMetalLBSpeaker implements the speaker.Speaker interface by delegating to a set of functions defined during test.

func (*MockMetalLBSpeaker) PeerSessions

func (m *MockMetalLBSpeaker) PeerSessions() []metallbspr.Session

func (*MockMetalLBSpeaker) SetNodeLabels

func (m *MockMetalLBSpeaker) SetNodeLabels(labels map[string]string) types.SyncState

func (*MockMetalLBSpeaker) SetService

type MockSession

type MockSession struct {
	Set_ func(advs ...*bgp.Advertisement) error
}

MockSession implements the metallbspr.Session interface and is useful when utilizing the PeerSession() method of a MockMetalLBSpeaker.

func (*MockSession) Close

func (m *MockSession) Close() error

Close is a no-op

func (*MockSession) Set

func (m *MockSession) Set(advs ...*bgp.Advertisement) error

Jump to

Keyboard shortcuts

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