Documentation ¶
Index ¶
- func GenTestCiliumNodeAndAdvertisements(numPodCIDRs int) (ciliumv2.CiliumNode, []*metallbbgp.Advertisement)
- func GenTestEndpointsPairs() (k8s.Endpoints, slim_corev1.Endpoints, metallbspr.Endpoints)
- func GenTestNodeAndAdvertisements() (v1.Node, []*metallbbgp.Advertisement)
- func GenTestServicePairs() (slim_corev1.Service, v1.Service, metallbspr.Service, k8s.ServiceID)
- type MockEndpointGetter
- type MockIndexer
- func (m *MockIndexer) Add(obj interface{}) error
- func (m *MockIndexer) Delete(obj interface{}) error
- func (m *MockIndexer) Get(obj interface{}) (item interface{}, exists bool, err error)
- func (m *MockIndexer) GetByKey(key string) (item interface{}, exists bool, err error)
- func (m *MockIndexer) List() []interface{}
- func (m *MockIndexer) ListKeys() []string
- func (m *MockIndexer) Replace([]interface{}, string) error
- func (m *MockIndexer) Resync() error
- func (m *MockIndexer) Update(obj interface{}) error
- type MockMetalLBController
- type MockMetalLBSpeaker
- func (m *MockMetalLBSpeaker) GetBGPController() *metallbspr.BGPController
- func (m *MockMetalLBSpeaker) PeerSessions() []metallbspr.Session
- func (m *MockMetalLBSpeaker) SetNodeLabels(labels map[string]string) types.SyncState
- func (m *MockMetalLBSpeaker) SetService(name string, svc *metallbspr.Service, eps *metallbspr.Endpoints) types.SyncState
- type MockSession
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, 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 ¶
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 ¶
func (m *MockMetalLBSpeaker) SetService(name string, svc *metallbspr.Service, eps *metallbspr.Endpoints) types.SyncState
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) Set ¶
func (m *MockSession) Set(advs ...*bgp.Advertisement) error