Skip to content

Commit 606dc0e

Browse files
committed
add error exit code e2e test
1 parent 5e956a3 commit 606dc0e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/e2e/job_error_handling.go

+38
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,42 @@ var _ = Describe("Job Error Handling", func() {
469469

470470
})
471471

472+
It("job level LifecyclePolicy, error code: 3; Action: RestartJob", func() {
473+
By("init test context")
474+
context := initTestContext()
475+
defer cleanupTestContext(context)
476+
477+
By("create job")
478+
var erroCode int32 = 3
479+
job := createJob(context, &jobSpec{
480+
name: "errorcode-restart-job",
481+
policies: []vkv1.LifecyclePolicy{
482+
{
483+
Action: vkv1.RestartJobAction,
484+
ExitCode: &erroCode,
485+
},
486+
},
487+
tasks: []taskSpec{
488+
{
489+
name: "success",
490+
img: defaultNginxImage,
491+
min: 1,
492+
rep: 1,
493+
},
494+
{
495+
name: "fail",
496+
img: defaultNginxImage,
497+
min: 1,
498+
rep: 1,
499+
command: "sleep 10s && exit 3",
500+
restartPolicy: v1.RestartPolicyNever,
501+
},
502+
},
503+
})
504+
505+
// job phase: pending -> running -> restarting
506+
err := waitJobPhases(context, job, []vkv1.JobPhase{vkv1.Pending, vkv1.Running, vkv1.Restarting})
507+
Expect(err).NotTo(HaveOccurred())
508+
})
509+
472510
})

0 commit comments

Comments
 (0)