Skip to content

controller/network: add unit tests for LCOW network controller#10

Closed
shreyanshjain7174 wants to merge 1 commit intorawahars:network-controllerfrom
shreyanshjain7174:controller/network-tests
Closed

controller/network: add unit tests for LCOW network controller#10
shreyanshjain7174 wants to merge 1 commit intorawahars:network-controllerfrom
shreyanshjain7174:controller/network-tests

Conversation

@shreyanshjain7174
Copy link

Stacked on microsoft#2633.

Adds 15 unit tests for the LCOW network controller (internal/controller/network/). Tests target production failure paths — resource cleanup chains, state corruption, and partially-torn-down NICs.

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

LCOW endpoint tests: host AddNIC before guest AddLCOWNetworkInterface (ordering enforced via gomock.InOrder), BuildLCOWNetworkAdapter struct verified against expected output, host-succeeds-guest-fails keeps NIC tracked for Teardown cleanup, host-AddNIC-fails does not track NIC, guest-remove-fails prevents host RemoveNIC call, nil capabilities disables guest-side ops.

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

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>
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.

1 participant