Skip to content

Commit

Permalink
controller, tests: assert updating an attachment MAC is not handled
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Duarte Barroso <[email protected]>
  • Loading branch information
maiqueb committed Nov 17, 2022
1 parent c291662 commit 89a958e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pkg/controller/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,46 @@ var _ = Describe("Dynamic Attachment controller", func() {
}).Should(BeEmpty())
})
})

When("an update to an existing attachment occurs", func() {
BeforeEach(func() {
var err error

currentPodAttachments, err := networkSelectionElements(pod.Annotations, pod.GetNamespace())
Expect(err).NotTo(HaveOccurred())
Expect(currentPodAttachments).NotTo(BeEmpty())

currentPodAttachments[0].MacRequest = "07:06:05:04:03:02"
var newAttachments []nad.NetworkSelectionElement
for i := range currentPodAttachments {
newAttachments = append(newAttachments, *currentPodAttachments[i])
}

serializedAttachments, err := json.Marshal(newAttachments)
Expect(err).NotTo(HaveOccurred())
pod.Annotations[nad.NetworkAttachmentAnnot] = string(serializedAttachments)

_, err = k8sClient.CoreV1().Pods(namespace).UpdateStatus(
context.TODO(),
pod,
metav1.UpdateOptions{})
Expect(err).NotTo(HaveOccurred())
})

It("nothing happens", func() {
Consistently(func() ([]nad.NetworkStatus, error) {
updatedPod, err := k8sClient.CoreV1().Pods(namespace).Get(context.TODO(), podName, metav1.GetOptions{})
if err != nil {
return nil, err
}
status, err := networkStatus(updatedPod.Annotations)
if err != nil {
return nil, err
}
return status, nil
}).Should(ConsistOf(ifaceStatus(namespace, networkName, "net0", "")))
})
})
})
})
})
Expand Down

0 comments on commit 89a958e

Please sign in to comment.