diff --git a/test/e2e/apps/job.go b/test/e2e/apps/job.go index 8c5f1e55a0f..0fcce8f5dab 100644 --- a/test/e2e/apps/job.go +++ b/test/e2e/apps/job.go @@ -59,6 +59,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")