diff --git a/test/e2e_node/container_lifecycle_test.go b/test/e2e_node/container_lifecycle_test.go index 6caf25bfca1..e60f28b140f 100644 --- a/test/e2e_node/container_lifecycle_test.go +++ b/test/e2e_node/container_lifecycle_test.go @@ -51,6 +51,7 @@ func prefixedName(namePrefix string, name string) string { var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", func() { f := framework.NewDefaultFramework("containers-lifecycle-test") + addAfterEachForCleaningUpPods(f) f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged ginkgo.It("should launch init container serially before a regular container", func() { @@ -909,6 +910,7 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() { f := framework.NewDefaultFramework("containers-lifecycle-test-serial") + addAfterEachForCleaningUpPods(f) f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) { @@ -1049,6 +1051,7 @@ var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() { var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func() { f := framework.NewDefaultFramework("containers-lifecycle-test") + addAfterEachForCleaningUpPods(f) f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged ginkgo.When("using a Pod with restartPolicy=Never, three init container and two restartable init containers", ginkgo.Ordered, func() { @@ -3119,6 +3122,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func( var _ = SIGDescribe(nodefeature.SidecarContainers, framework.WithSerial(), "Containers Lifecycle", func() { f := framework.NewDefaultFramework("containers-lifecycle-test-serial") + addAfterEachForCleaningUpPods(f) f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) { diff --git a/test/e2e_node/pids_test.go b/test/e2e_node/pids_test.go index adf1f4ad4ec..f6b5d2d448f 100644 --- a/test/e2e_node/pids_test.go +++ b/test/e2e_node/pids_test.go @@ -128,5 +128,6 @@ var _ = SIGDescribe("PodPidsLimit", framework.WithSerial(), func() { initialConfig.PodPidsLimit = int64(1024) }) runPodPidsLimitTests(f) + addAfterEachForCleaningUpPods(f) }) }) diff --git a/test/e2e_node/pod_conditions_test.go b/test/e2e_node/pod_conditions_test.go index c15285ed92e..75912482f4d 100644 --- a/test/e2e_node/pod_conditions_test.go +++ b/test/e2e_node/pod_conditions_test.go @@ -58,7 +58,7 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() { ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, true)) ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, true)) ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, true)) - cleanupPods(f) + addAfterEachForCleaningUpPods(f) }) ginkgo.Context("without PodReadyToStartContainersCondition condition", func() { @@ -66,7 +66,7 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() { ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, false)) ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, false)) ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, false)) - cleanupPods(f) + addAfterEachForCleaningUpPods(f) }) }) diff --git a/test/e2e_node/quota_lsci_test.go b/test/e2e_node/quota_lsci_test.go index f7061cfb22b..a0cfd494895 100644 --- a/test/e2e_node/quota_lsci_test.go +++ b/test/e2e_node/quota_lsci_test.go @@ -103,6 +103,7 @@ var _ = SIGDescribe("LocalStorageCapacityIsolationFSQuotaMonitoring", framework. f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged runOneQuotaTest(f, true) runOneQuotaTest(f, false) + addAfterEachForCleaningUpPods(f) }) const ( diff --git a/test/e2e_node/swap_test.go b/test/e2e_node/swap_test.go index 824dfd9fe13..7dccb62ce70 100644 --- a/test/e2e_node/swap_test.go +++ b/test/e2e_node/swap_test.go @@ -56,8 +56,9 @@ var ( noLimits *resource.Quantity = nil ) -var _ = SIGDescribe("Swap", "[LinuxOnly]", nodefeature.Swap, func() { +var _ = SIGDescribe("Swap", "[LinuxOnly]", nodefeature.Swap, framework.WithSerial(), func() { f := framework.NewDefaultFramework("swap-qos") + addAfterEachForCleaningUpPods(f) f.NamespacePodSecurityLevel = admissionapi.LevelBaseline ginkgo.BeforeEach(func() { diff --git a/test/e2e_node/util.go b/test/e2e_node/util.go index 3d6fe0cf1e3..7318284f679 100644 --- a/test/e2e_node/util.go +++ b/test/e2e_node/util.go @@ -171,7 +171,7 @@ func getCurrentKubeletConfig(ctx context.Context) (*kubeletconfig.KubeletConfigu return e2enodekubelet.GetCurrentKubeletConfig(ctx, framework.TestContext.NodeName, "", false, framework.TestContext.StandaloneMode) } -func cleanupPods(f *framework.Framework) { +func addAfterEachForCleaningUpPods(f *framework.Framework) { ginkgo.AfterEach(func(ctx context.Context) { ginkgo.By("Deleting any Pods created by the test in namespace: " + f.Namespace.Name) l, err := e2epod.NewPodClient(f).List(ctx, metav1.ListOptions{})