Skip to content

Commit

Permalink
e2e tests: add test removing an iface from a network w/ IPAM
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <[email protected]>
  • Loading branch information
maiqueb committed Oct 17, 2022
1 parent 769e549 commit 9de0ac3
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,28 @@ var _ = Describe("Multus dynamic networks controller", func() {
})

Context("a network with IPAM", func() {
const ipamNetworkToAdd = "tenant-network-ipam"
const (
ifaceToAddWithIPAM = "ens202"
ipAddressToAdd = "10.10.10.111"
ipamNetworkToAdd = "tenant-network-ipam"
netmaskLen = 24
)

macAddress := "02:03:04:05:06:07"

BeforeEach(func() {
_, err := clients.AddNetAttachDef(macvlanNetworkWitStaticIPAM(ipamNetworkToAdd, namespace))
Expect(err).NotTo(HaveOccurred())
})

It("can be hotplugged into a running pod", func() {
const (
ifaceToAddWithIPAM = "ens202"
ipAddressToAdd = "10.10.10.111"
netmaskLen = 24
)

macAddress := "02:03:04:05:06:07"
Expect(clients.AddNetworkToPod(pod, &nettypes.NetworkSelectionElement{
Name: ipamNetworkToAdd,
Namespace: namespace,
IPRequest: []string{ipWithMask(ipAddressToAdd, netmaskLen)},
InterfaceRequest: ifaceToAddWithIPAM,
MacRequest: macAddress,
})).To(Succeed())
})

It("can be hotplugged into a running pod", func() {
Eventually(filterPodNonDefaultNetworks).Should(
ContainElements(
nettypes.NetworkStatus{
Expand All @@ -152,6 +152,24 @@ var _ = Describe("Multus dynamic networks controller", func() {
},
))
})

It("can be hot unplugged from a running pod", func() {
const ifaceToRemove = ifaceToAddWithIPAM
pods, err := clients.ListPods(namespace, fmt.Sprintf("app=%s", podName))
Expect(err).NotTo(HaveOccurred())
pod = &pods.Items[0]

Expect(clients.RemoveNetworkFromPod(pod, networkName, namespace, ifaceToRemove)).To(Succeed())
Eventually(filterPodNonDefaultNetworks).Should(
Not(ContainElements(
nettypes.NetworkStatus{
Name: namespacedName(namespace, ipamNetworkToAdd),
Interface: ifaceToAddWithIPAM,
IPs: []string{ipAddressToAdd},
Mac: macAddress,
},
)))
})
})
})
})
Expand Down

0 comments on commit 9de0ac3

Please sign in to comment.