From 24eee5725039a32887f3dce7e44e0a091a25537a Mon Sep 17 00:00:00 2001 From: Rajadeepan D Ramesh Date: Tue, 9 Jul 2019 16:55:48 +0530 Subject: [PATCH] Adding e2e test case for multiple events in lifecycle policy --- test/e2e/job_error_handling.go | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/e2e/job_error_handling.go b/test/e2e/job_error_handling.go index 73287a9e71d..f52b6d86484 100644 --- a/test/e2e/job_error_handling.go +++ b/test/e2e/job_error_handling.go @@ -507,4 +507,51 @@ var _ = Describe("Job Error Handling", func() { Expect(err).NotTo(HaveOccurred()) }) + It("job level LifecyclePolicy, Event[]: PodEvicted, PodFailed; Action: TerminateJob", func() { + By("init test context") + context := initTestContext() + defer cleanupTestContext(context) + + By("create job") + job := createJob(context, &jobSpec{ + name: "evicted-terminate-job", + policies: []vkv1.LifecyclePolicy{ + { + Action: vkv1.TerminateJobAction, + Events: []vkv1.Event{vkv1.PodEvictedEvent, + vkv1.PodFailedEvent, + vkv1.PodEvictedEvent, + }, + }, + }, + tasks: []taskSpec{ + { + name: "success", + img: defaultNginxImage, + min: 2, + rep: 2, + }, + { + name: "delete", + img: defaultNginxImage, + min: 2, + rep: 2, + }, + }, + }) + + // job phase: pending -> running + err := waitJobPhases(context, job, []vkv1.JobPhase{vkv1.Pending, vkv1.Inqueue, vkv1.Running}) + Expect(err).NotTo(HaveOccurred()) + + By("delete one pod of job") + podName := jobutil.MakePodName(job.Name, "delete", 0) + err = context.kubeclient.CoreV1().Pods(job.Namespace).Delete(podName, &metav1.DeleteOptions{}) + Expect(err).NotTo(HaveOccurred()) + + // job phase: Terminating -> Terminated + err = waitJobPhases(context, job, []vkv1.JobPhase{vkv1.Terminating, vkv1.Terminated}) + Expect(err).NotTo(HaveOccurred()) + }) + })