From 8e060251899f99e68c312e6b97d2a585d0a0fc72 Mon Sep 17 00:00:00 2001 From: Miguel Duarte Barroso Date: Wed, 26 Apr 2023 09:44:50 +0200 Subject: [PATCH] e2e test: ensure pods are gone on test teardown Signed-off-by: Miguel Duarte Barroso --- e2e/e2e_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 174fb40e..c142ed0a 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -62,6 +62,14 @@ var _ = Describe("Multus dynamic networks controller", func() { }) } + isTestNamespaceEmpty := func() bool { + pods, err := clients.ListPods(namespace, appLabel(podName)) + if err != nil { + return false + } + return len(pods.Items) == 0 + } + Context("a provisioned pod having network selection elements", func() { var pod *corev1.Pod @@ -93,6 +101,7 @@ var _ = Describe("Multus dynamic networks controller", func() { AfterEach(func() { Expect(clients.DeletePod(pod)).To(Succeed()) + Eventually(isTestNamespaceEmpty, timeout).Should(BeTrue()) }) It("manages to add a new interface to a running pod", func() { @@ -190,6 +199,7 @@ var _ = Describe("Multus dynamic networks controller", func() { AfterEach(func() { Expect(clients.DeletePod(pod)).To(Succeed()) + Eventually(isTestNamespaceEmpty, timeout).Should(BeTrue()) }) It("manages to add a new interface to a running pod", func() { @@ -267,6 +277,7 @@ var _ = Describe("Multus dynamic networks controller", func() { AfterEach(func() { Expect(clients.DeletePod(pod)).To(Succeed()) + Eventually(isTestNamespaceEmpty, timeout).Should(BeTrue()) }) runningPod := func() *corev1.Pod {