Skip to content

Conversation

@aritrbas
Copy link
Collaborator

@aritrbas aritrbas commented Nov 26, 2025

Summary

This PR introduces Ginkgo based tests for vpp-manager component.

Architecture

┌────────────────────────────────────────────────────────────────────┐
│                     Host Machine                                   │
│                                                                    │
│   ┌─────────────────────────────────────────────────────────────┐  │
│   │              Test Process (go test)                         │  │
│   │                                                             │  │
│   │  ┌─────────────────┐    ┌────────────────────────────────┐  │  │
│   │  │  VppFixture     │    │  vpp_manager_test.go           │  │  │
│   │  │ (pkg/testutils) │    │                                │  │  │
│   │  │                 │    │  - Creates VppRunner           │  │  │
│   │  │  - Start VPP    │    │  - Calls vpp_runner.go methods │  │  │
│   │  │  - Connect API  │    │  - Verifies VPP state          │  │  │
│   │  └────────┬────────┘    └────────────────────────────────┘  │  │
│   │           │                                                 │  │
│   └───────────┼─────────────────────────────────────────────────┘  │
│               │                                                    │
│               ▼                                                    │
│   ┌─────────────────────────────────────────────────────────────┐  │
│   │              Docker Container (VPP)                         │  │
│   │                                                             │  │
│   │  ┌───────────────────────────────────────────────────────┐  │  │
│   │  │                VPP Process                            │  │  │
│   │  │                                                       │  │  │
│   │  │  - API socket: /var/run/vpp/vpp-api-test.sock         │  │  │
│   │  │  - CLI socket: /var/run/vpp/cli.sock                  │  │  │
│   │  │                                                       │  │  │
│   │  └───────────────────────────────────────────────────────┘  │  │
│   │                                                             │  │
│   │  Volume Mount: /tmp/vpp-test-<name>/:/var/run/vpp/          │  │
│   │                                                             │  │
│   └─────────────────────────────────────────────────────────────┘  │
│                                                                    │
└────────────────────────────────────────────────────────────────────┘

Environment Variables

Variable Default Description
VPP_IMAGE (required) Docker image containing VPP
VPP_BINARY /usr/bin/vpp Path to VPP binary inside container

Test Structure

vpp-manager/
└── vpp_manager_test.go     # Tests

pkg/testutils/
├── vpp_instance.go         # VPP container management
├── fixtures.go             # Ginkgo fixtures
├── assertions.go           # VPP state assertions
└── helpers.go              # Helper functions

Test Coverage

Test Description
VppRunner.allocateStaticVRFs Verifies punt-table and calico-pods VRFs are created for IPv4/IPv6
VppRunner.AllocatePhysicalNetworkVRFs Verifies physical network VRF allocation and config.Info registration
VPP Configuration Verifies buffer allocation and plugin configuration in VPP
uplink Interface Tests uplink interface addresses and VRFs configuration
TAP Interface Tests TAP interface creation
AF_PACKET Interface Tests AF_PACKET interface creation on veth pairs
memif Interface Tests memif interface creation

Running Tests

make test

The tests are integrated into the main make test target:

# Build VPP image and run all tests
make test

# The test command includes these settings:
# sudo -E env "PATH=$$PATH" VPP_BINARY=/usr/bin/vpp \
#     VPP_IMAGE=calicovpp/vpp:$(TAG) \
#     go test ./... \
#     -cover -covermode=atomic -p 1 -test.v \
#     -test.gocoverdir=$(shell pwd)/.coverage/unit

go test

# Set environment variables
export VPP_IMAGE=calicovpp/vpp:latest
export VPP_BINARY=/usr/bin/vpp

# Run vpp-manager tests only
sudo -E go test -v ./vpp-manager/...

# Run with verbose Ginkgo output
sudo -E go test -v -ginkgo.v ./vpp-manager/...

# Run specific test by focus
sudo -E go test -v -ginkgo.focus="allocateStaticVRFs" ./vpp-manager/...

@aritrbas aritrbas self-assigned this Nov 26, 2025
@aritrbas aritrbas marked this pull request as draft November 26, 2025 09:05
@aritrbas aritrbas force-pushed the abasu-vpp-manager-test branch 3 times, most recently from fd955e4 to cec41af Compare December 2, 2025 08:53
@aritrbas aritrbas marked this pull request as ready for review December 2, 2025 08:56
Copy link
Collaborator

@sknat sknat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a stab at it @aritrbas !
A few comments on the structure. Tell me if you want to discuss it in more details

}

// ConfigureUplink configures a TAP interface as uplink with the specified configuration
func (v *VppInstance) ConfigureUplink(config *UplinkConfig) (uint32, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could call vpp_runner.go:configureVppUplinkInterface() directly instead of having a custom logic for tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran into some issues while trying to test VppRunner.configureVppUplinkInterface() directly.
It creates a TAP with HostNamespace:"pid:1" that requires access to the host's PID 1 network namespace. In a Docker container, pid:1 refers to the container's init process, not the host, causing the Linux-side tap setup to fail.

For now, I have added a very basic uplink interface test that only verifies the VPP-side operations performed in configureVppUplinkInterface() - (i) VRF allocation (via allocateStaticVRFs()) (ii) Interface address configuration (via AddInterfaceAddress()) (iii) Interface state management (via InterfaceAdminUp())

Need to discuss how we can test the entire VppRunner.configureVppUplinkInterface() functionality using this framework, maybe handle it as a part of a separate task/PR?

@aritrbas aritrbas force-pushed the abasu-vpp-manager-test branch 2 times, most recently from d63bedd to 2bbd152 Compare December 3, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants