test

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package test provides utilities for testing the AWS Multi-ENI Controller.

Index

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

func CreateTestLogger(t *testing.T) logr.Logger

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

func SkipIfNoAWSCredentials(t *testing.T)

SkipIfNoAWSCredentials skips the test if AWS credentials are not available

func SkipIfNoKubernetesCluster

func SkipIfNoKubernetesCluster(t *testing.T)

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) Scheme

func (m *MockClient) Scheme() *runtime.Scheme

Scheme returns the scheme

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

func (*MockEventRecorder) Event

func (m *MockEventRecorder) Event(object runtime.Object, eventtype, reason, message string)

Event records an event

func (*MockEventRecorder) Eventf

func (m *MockEventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf records an event with formatting

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

func (*MockNodeENIController) Reconcile

Reconcile reconciles a NodeENI resource

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

Patch patches the status of an object

func (*MockStatusWriter) Update

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

Create creates a subresource

func (*MockSubResourceClient) Get

Get gets a subresource

func (*MockSubResourceClient) Patch

Patch patches a subresource

func (*MockSubResourceClient) Update

Update updates a subresource

Jump to

Keyboard shortcuts

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