Documentation
¶
Overview ¶
Package test provides utilities for testing the AWS Multi-ENI Controller.
Index ¶
- func CreateMockEC2Client() *awsutil.MockEC2Client
- func CreateTestEC2Client(t *testing.T) awsutil.EC2Interface
- func CreateTestLogger(t *testing.T) logr.Logger
- func CreateTestNodeENI(name string, nodeSelector map[string]string, subnetID string, ...) *networkingv1alpha1.NodeENI
- func CreateTestNodeENIWithDPDK(name string, nodeSelector map[string]string, subnetID string, ...) *networkingv1alpha1.NodeENI
- func CreateTestNodeENIWithMTU(name string, nodeSelector map[string]string, subnetID string, ...) *networkingv1alpha1.NodeENI
- func CreateTestNodeENIWithMultipleSubnets(name string, nodeSelector map[string]string, subnetIDs []string, ...) *networkingv1alpha1.NodeENI
- func CreateTestNodeENIWithSubnetName(name string, nodeSelector map[string]string, subnetName string, ...) *networkingv1alpha1.NodeENI
- func SkipIfNoAWSCredentials(t *testing.T)
- func SkipIfNoKubernetesCluster(t *testing.T)
- type MockClient
- func (m *MockClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (m *MockClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (m *MockClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (m *MockClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (m *MockClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (m *MockClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (m *MockClient) RESTMapper() meta.RESTMapper
- func (m *MockClient) Scheme() *runtime.Scheme
- func (m *MockClient) Status() client.StatusWriter
- func (m *MockClient) SubResource(subResource string) client.SubResourceClient
- func (m *MockClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type MockEventRecorder
- type MockNodeENIController
- type MockStatusWriter
- func (m *MockStatusWriter) Create(ctx context.Context, obj client.Object, subResource client.Object, ...) error
- func (m *MockStatusWriter) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (m *MockStatusWriter) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
- type MockSubResourceClient
- func (m *MockSubResourceClient) Create(ctx context.Context, obj client.Object, subResource client.Object, ...) error
- func (m *MockSubResourceClient) Get(ctx context.Context, obj client.Object, subResource client.Object, ...) error
- func (m *MockSubResourceClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (m *MockSubResourceClient) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMockEC2Client ¶
func CreateMockEC2Client() *awsutil.MockEC2Client
CreateMockEC2Client creates a mock EC2 client for unit testing
func CreateTestEC2Client ¶
func CreateTestEC2Client(t *testing.T) awsutil.EC2Interface
CreateTestEC2Client creates a real EC2 client for integration testing
func CreateTestLogger ¶
CreateTestLogger creates a logger for testing
func CreateTestNodeENI ¶
func CreateTestNodeENI(name string, nodeSelector map[string]string, subnetID string, securityGroupIDs []string, deviceIndex int) *networkingv1alpha1.NodeENI
CreateTestNodeENI creates a NodeENI resource for testing
func CreateTestNodeENIWithDPDK ¶
func CreateTestNodeENIWithDPDK(name string, nodeSelector map[string]string, subnetID string, securityGroupIDs []string, deviceIndex int, enableDPDK bool, dpdkDriver string, dpdkResourceName string, dpdkPCIAddress string) *networkingv1alpha1.NodeENI
CreateTestNodeENIWithDPDK creates a NodeENI resource with DPDK configuration for testing
func CreateTestNodeENIWithMTU ¶
func CreateTestNodeENIWithMTU(name string, nodeSelector map[string]string, subnetID string, securityGroupIDs []string, deviceIndex int, mtu int) *networkingv1alpha1.NodeENI
CreateTestNodeENIWithMTU creates a NodeENI resource with MTU configuration for testing
func CreateTestNodeENIWithMultipleSubnets ¶
func CreateTestNodeENIWithMultipleSubnets(name string, nodeSelector map[string]string, subnetIDs []string, securityGroupIDs []string, deviceIndex int) *networkingv1alpha1.NodeENI
CreateTestNodeENIWithMultipleSubnets creates a NodeENI resource with multiple subnets for testing
func CreateTestNodeENIWithSubnetName ¶
func CreateTestNodeENIWithSubnetName(name string, nodeSelector map[string]string, subnetName string, securityGroupIDs []string, deviceIndex int) *networkingv1alpha1.NodeENI
CreateTestNodeENIWithSubnetName creates a NodeENI resource with subnet name for testing
func SkipIfNoAWSCredentials ¶
SkipIfNoAWSCredentials skips the test if AWS credentials are not available
func SkipIfNoKubernetesCluster ¶
SkipIfNoKubernetesCluster skips the test if a Kubernetes cluster is not available
Types ¶
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock implementation of client.Client
func NewMockClient ¶
func NewMockClient(scheme *runtime.Scheme) *MockClient
NewMockClient creates a new mock client
func (*MockClient) Create ¶
func (m *MockClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
Create creates an object
func (*MockClient) Delete ¶
func (m *MockClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
Delete deletes an object
func (*MockClient) DeleteAllOf ¶
func (m *MockClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf deletes all objects of a type
func (*MockClient) Get ¶
func (m *MockClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error
Get retrieves an object
func (*MockClient) List ¶
func (m *MockClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List retrieves a list of objects
func (*MockClient) Patch ¶
func (m *MockClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
Patch patches an object
func (*MockClient) RESTMapper ¶
func (m *MockClient) RESTMapper() meta.RESTMapper
RESTMapper returns a RESTMapper
func (*MockClient) Status ¶
func (m *MockClient) Status() client.StatusWriter
Status returns a StatusWriter for updating status
func (*MockClient) SubResource ¶
func (m *MockClient) SubResource(subResource string) client.SubResourceClient
SubResource returns a SubResourceClient for accessing subresources
func (*MockClient) Update ¶
func (m *MockClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
Update updates an object
type MockEventRecorder ¶
type MockEventRecorder struct { Events []string // contains filtered or unexported fields }
MockEventRecorder is a mock implementation of record.EventRecorder
func NewMockEventRecorder ¶
func NewMockEventRecorder() *MockEventRecorder
NewMockEventRecorder creates a new mock event recorder
func (*MockEventRecorder) AnnotatedEventf ¶
func (m *MockEventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})
AnnotatedEventf records an event with annotations
type MockNodeENIController ¶
type MockNodeENIController struct { Client client.Client AWS *awsutil.MockEC2Client Log logr.Logger Recorder *MockEventRecorder Config *config.ControllerConfig }
MockNodeENIController is a mock implementation of the NodeENI controller for testing
func NewMockNodeENIController ¶
func NewMockNodeENIController(client client.Client, aws *awsutil.MockEC2Client, log logr.Logger, recorder *MockEventRecorder) *MockNodeENIController
NewMockNodeENIController creates a new mock NodeENI controller
type MockStatusWriter ¶
type MockStatusWriter struct {
// contains filtered or unexported fields
}
MockStatusWriter is a mock implementation of client.StatusWriter
func (*MockStatusWriter) Create ¶
func (m *MockStatusWriter) Create(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceCreateOption) error
Create creates the status of an object
func (*MockStatusWriter) Patch ¶
func (m *MockStatusWriter) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error
Patch patches the status of an object
func (*MockStatusWriter) Update ¶
func (m *MockStatusWriter) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
Update updates the status of an object
type MockSubResourceClient ¶
type MockSubResourceClient struct {
// contains filtered or unexported fields
}
MockSubResourceClient is a mock implementation of client.SubResourceClient
func (*MockSubResourceClient) Create ¶
func (m *MockSubResourceClient) Create(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceCreateOption) error
Create creates a subresource
func (*MockSubResourceClient) Get ¶
func (m *MockSubResourceClient) Get(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceGetOption) error
Get gets a subresource
func (*MockSubResourceClient) Patch ¶
func (m *MockSubResourceClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error
Patch patches a subresource
func (*MockSubResourceClient) Update ¶
func (m *MockSubResourceClient) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
Update updates a subresource