mock

package
v1.14.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenTestCiliumNodeAndAdvertisements

func GenTestCiliumNodeAndAdvertisements(numPodCIDRs int) (ciliumv2.CiliumNode, []*metallbbgp.Advertisement)

GenTestCiliumNodeAndAdvertisements generates a ciliumv2.CiliumNode with numPodCIDRs podCIDRs and the corresponding 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 GenTestEndpointsPairs

func GenTestEndpointsPairs() (k8s.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() (slim_corev1.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
	GetBGPController_ func() *metallbspr.BGPController
}

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

func (*MockMetalLBSpeaker) GetBGPController

func (m *MockMetalLBSpeaker) GetBGPController() *metallbspr.BGPController

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