Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send desired IP / MAC address to multus server #39

Merged
merged 5 commits into from
Oct 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
phoracek marked this conversation as resolved.
Show resolved Hide resolved

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