Skip to content

controller/network: add unit tests for network controller#2647

Open
shreyanshjain7174 wants to merge 3 commits intomicrosoft:mainfrom
shreyanshjain7174:controller/network-tests
Open

controller/network: add unit tests for network controller#2647
shreyanshjain7174 wants to merge 3 commits intomicrosoft:mainfrom
shreyanshjain7174:controller/network-tests

Conversation

@shreyanshjain7174
Copy link
Contributor

@shreyanshjain7174 shreyanshjain7174 commented Mar 25, 2026

Depends on #2633 — must merge first.

Adds unit tests for the network controller (internal/controller/network/). 22 tests across LCOW and WCOW, biased toward resource cleanup chains and state corruption rather than guard-check permutations.

Teardown: continue-on-error when one NIC removal fails (remaining NICs still attempted, failed NICs stay tracked for retry), retry from Invalid state, idempotent when TornDown, no-op when NotConfigured, full Configured→TornDown lifecycle. Setup rejects duplicate calls.

LCOW endpoint ops: host AddNIC before guest AddLCOWNetworkInterface (ordering enforced via gomock.InOrder), BuildLCOWNetworkAdapter struct verified, host-fail→not tracked, guest-fail→still tracked for Teardown cleanup, guest-remove-fails→host RemoveNIC not called, nil capabilities disables guest ops.

WCOW endpoint ops: 3-phase add (PreAdd → host AddNIC → guest Add), PreAdd failure→not tracked, guest-finalize failure→still tracked, remove ordering (guest before host), namespace add with/without guest support.

Mocks generated for vmNetworkManager, linuxGuestNetworkManager, windowsGuestNetworkManager, and capabilitiesProvider. GuestDefinedCapabilities mock reused from internal/gcs/mock/.

rawahars and others added 3 commits March 21, 2026 00:31
This change adds the network controller implementation for V2 shims which manages the network lifecycle for a single pod running inside a UVM.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
15 tests covering teardown cleanup chains (partial NIC failure continues,
failed NICs stay tracked for retry from Invalid state), state machine
transitions (idempotent teardown, no-op on unconfigured, duplicate Setup
rejected), LCOW endpoint add/remove operations (host-before-guest ordering
via InOrder, BuildLCOWNetworkAdapter struct verification, guest-fail still
tracked for cleanup, host-fail not tracked), nil-capabilities disabling
guest ops, and State.String().

Mocks generated for vmNetworkManager, linuxGuestNetworkManager, and
capabilitiesProvider. GCS GuestDefinedCapabilities mock reused from
internal/gcs/mock/.

Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
@shreyanshjain7174 shreyanshjain7174 requested a review from a team as a code owner March 25, 2026 07:26
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