[e2e-node] Cleanup pods after the test runs
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
		@@ -51,6 +51,7 @@ func prefixedName(namePrefix string, name string) string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", func() {
 | 
					var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", func() {
 | 
				
			||||||
	f := framework.NewDefaultFramework("containers-lifecycle-test")
 | 
						f := framework.NewDefaultFramework("containers-lifecycle-test")
 | 
				
			||||||
 | 
						addAfterEachForCleaningUpPods(f)
 | 
				
			||||||
	f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
						f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ginkgo.It("should launch init container serially before a regular container", func() {
 | 
						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() {
 | 
					var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() {
 | 
				
			||||||
	f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
 | 
						f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
 | 
				
			||||||
 | 
						addAfterEachForCleaningUpPods(f)
 | 
				
			||||||
	f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
						f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) {
 | 
						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() {
 | 
					var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func() {
 | 
				
			||||||
	f := framework.NewDefaultFramework("containers-lifecycle-test")
 | 
						f := framework.NewDefaultFramework("containers-lifecycle-test")
 | 
				
			||||||
 | 
						addAfterEachForCleaningUpPods(f)
 | 
				
			||||||
	f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
						f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ginkgo.When("using a Pod with restartPolicy=Never, three init container and two restartable init containers", ginkgo.Ordered, func() {
 | 
						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() {
 | 
					var _ = SIGDescribe(nodefeature.SidecarContainers, framework.WithSerial(), "Containers Lifecycle", func() {
 | 
				
			||||||
	f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
 | 
						f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
 | 
				
			||||||
 | 
						addAfterEachForCleaningUpPods(f)
 | 
				
			||||||
	f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
						f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) {
 | 
						ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -128,5 +128,6 @@ var _ = SIGDescribe("PodPidsLimit", framework.WithSerial(), func() {
 | 
				
			|||||||
			initialConfig.PodPidsLimit = int64(1024)
 | 
								initialConfig.PodPidsLimit = int64(1024)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		runPodPidsLimitTests(f)
 | 
							runPodPidsLimitTests(f)
 | 
				
			||||||
 | 
							addAfterEachForCleaningUpPods(f)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 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 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))
 | 
							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() {
 | 
						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 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 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))
 | 
							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)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103,6 +103,7 @@ var _ = SIGDescribe("LocalStorageCapacityIsolationFSQuotaMonitoring", framework.
 | 
				
			|||||||
	f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
						f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
 | 
				
			||||||
	runOneQuotaTest(f, true)
 | 
						runOneQuotaTest(f, true)
 | 
				
			||||||
	runOneQuotaTest(f, false)
 | 
						runOneQuotaTest(f, false)
 | 
				
			||||||
 | 
						addAfterEachForCleaningUpPods(f)
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,8 +56,9 @@ var (
 | 
				
			|||||||
	noLimits *resource.Quantity = nil
 | 
						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")
 | 
						f := framework.NewDefaultFramework("swap-qos")
 | 
				
			||||||
 | 
						addAfterEachForCleaningUpPods(f)
 | 
				
			||||||
	f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
 | 
						f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ginkgo.BeforeEach(func() {
 | 
						ginkgo.BeforeEach(func() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -171,7 +171,7 @@ func getCurrentKubeletConfig(ctx context.Context) (*kubeletconfig.KubeletConfigu
 | 
				
			|||||||
	return e2enodekubelet.GetCurrentKubeletConfig(ctx, framework.TestContext.NodeName, "", false, framework.TestContext.StandaloneMode)
 | 
						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.AfterEach(func(ctx context.Context) {
 | 
				
			||||||
		ginkgo.By("Deleting any Pods created by the test in namespace: " + f.Namespace.Name)
 | 
							ginkgo.By("Deleting any Pods created by the test in namespace: " + f.Namespace.Name)
 | 
				
			||||||
		l, err := e2epod.NewPodClient(f).List(ctx, metav1.ListOptions{})
 | 
							l, err := e2epod.NewPodClient(f).List(ctx, metav1.ListOptions{})
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user