From 86f13ecb5a62ab7243c92b3c12f6f79375ce8a8e Mon Sep 17 00:00:00 2001 From: globervinodhn Date: Thu, 6 Jun 2019 10:39:46 +0530 Subject: [PATCH] New E2E to verify pods are deleted after Job deletion --- test/e2e/apps/job.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/e2e/apps/job.go b/test/e2e/apps/job.go index b9a433c5081..5f35dde3b09 100644 --- a/test/e2e/apps/job.go +++ b/test/e2e/apps/job.go @@ -57,6 +57,30 @@ var _ = SIGDescribe("Job", func() { } }) + /* + Testcase: Ensure that the pods associated with the job are removed once the job is deleted + Description: Create a job and ensure the associated pod count is equal to paralellism count. Delete the + job and ensure if the pods associated with the job have been removed + */ + ginkgo.It("should remove pods when job is deleted", func() { + ginkgo.By("Creating a job") + job := jobutil.NewTestJob("notTerminate", "all-pods-removed", v1.RestartPolicyNever, parallelism, completions, nil, backoffLimit) + job, err := jobutil.CreateJob(f.ClientSet, f.Namespace.Name, job) + framework.ExpectNoError(err, "failed to create job in namespace: %s", f.Namespace.Name) + + ginkgo.By("Ensure pods equal to paralellism count is attached to the job") + err = jobutil.WaitForAllJobPodsRunning(f.ClientSet, f.Namespace.Name, job.Name, parallelism) + framework.ExpectNoError(err, "failed to ensure number of pods associated with job %s is equal to parallelism count in namespace: %s", job.Name, f.Namespace.Name) + + ginkgo.By("Delete the job") + err = framework.DeleteResourceAndWaitForGC(f.ClientSet, batchinternal.Kind("Job"), f.Namespace.Name, job.Name) + framework.ExpectNoError(err, "failed to delete the job in namespace: %s", f.Namespace.Name) + + ginkgo.By("Ensure the pods associated with the job are also deleted") + err = jobutil.WaitForAllJobPodsGone(f.ClientSet, f.Namespace.Name, job.Name) + framework.ExpectNoError(err, "failed to get PodList for job %s in namespace: %s", job.Name, f.Namespace.Name) + }) + // Pods sometimes fail, but eventually succeed. ginkgo.It("should run a job to completion when tasks sometimes fail and are locally restarted", func() { ginkgo.By("Creating a job")