Skip to content

Commit

Permalink
test: adding coverage that vm controller cleans up nics
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce-Soghigian committed Jan 16, 2025
1 parent 34476f0 commit 20c6625
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/controllers/nodeclaim/garbagecollection/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,31 @@ var _ = Describe("NetworkInterface Garbage Collection", func() {
Expect(len(nicsAfterGC)).To(Equal(1))

})
It("the vm gc controller should remove the nic if there is an associated vm", func() {
managedNic := Interface(
InterfaceOptions{
Tags: ManagedTags(nodePool.Name),
},
)
azureEnv.NetworkInterfacesAPI.NetworkInterfaces.Store(lo.FromPtr(managedNic.ID), *managedNic)
managedVM := VirtualMachine(
VirtualMachineOptions{
Name: lo.FromPtr(managedNic.Name),
Tags: ManagedTags(nodePool.Name),
},
)
azureEnv.VirtualMachinesAPI.VirtualMachinesBehavior.Instances.Store(lo.FromPtr(managedVM.ID), *managedVM)
ExpectSingletonReconciled(ctx, networkInterfaceGCController)
// We should still have a network interface here
nicsAfterGC, err := azureEnv.InstanceProvider.ListNics(ctx)
ExpectNoError(err)
Expect(len(nicsAfterGC)).To(Equal(1))

ExpectSingletonReconciled(ctx, virtualMachineGCController)
nicsAfterVMReconcilation, err := azureEnv.InstanceProvider.ListNics(ctx)
ExpectNoError(err)
Expect(len(nicsAfterVMReconcilation)).To(Equal(0))

})

})

0 comments on commit 20c6625

Please sign in to comment.