|
|
|
@ -241,39 +241,44 @@ func Test_ReadyChecker_jobReady(t *testing.T) {
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "job is completed",
|
|
|
|
|
args: args{job: newJob("foo", 1, 1, 1, 0)},
|
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 1, 0)},
|
|
|
|
|
want: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "job is incomplete",
|
|
|
|
|
args: args{job: newJob("foo", 1, 1, 0, 0)},
|
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 0)},
|
|
|
|
|
want: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "job is failed",
|
|
|
|
|
args: args{job: newJob("foo", 1, 1, 0, 1)},
|
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 1)},
|
|
|
|
|
want: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "job is completed with retry",
|
|
|
|
|
args: args{job: newJob("foo", 1, 1, 1, 1)},
|
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 1, 1)},
|
|
|
|
|
want: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "job is failed with retry",
|
|
|
|
|
args: args{job: newJob("foo", 1, 1, 0, 2)},
|
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 2)},
|
|
|
|
|
want: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "job is completed single run",
|
|
|
|
|
args: args{job: newJob("foo", 0, 1, 1, 0)},
|
|
|
|
|
args: args{job: newJob("foo", 0, intToInt32(1), 1, 0)},
|
|
|
|
|
want: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "job is failed single run",
|
|
|
|
|
args: args{job: newJob("foo", 0, 1, 0, 1)},
|
|
|
|
|
args: args{job: newJob("foo", 0, intToInt32(1), 0, 1)},
|
|
|
|
|
want: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "job with null completions",
|
|
|
|
|
args: args{job: newJob("foo", 0, nil, 1, 0)},
|
|
|
|
|
want: true,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
@ -481,7 +486,7 @@ func newPersistentVolumeClaim(name string, phase corev1.PersistentVolumeClaimPha
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newJob(name string, backoffLimit, completions, succeeded, failed int) *batchv1.Job {
|
|
|
|
|
func newJob(name string, backoffLimit int, completions *int32, succeeded int, failed int) *batchv1.Job {
|
|
|
|
|
return &batchv1.Job{
|
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
|
Name: name,
|
|
|
|
@ -489,7 +494,7 @@ func newJob(name string, backoffLimit, completions, succeeded, failed int) *batc
|
|
|
|
|
},
|
|
|
|
|
Spec: batchv1.JobSpec{
|
|
|
|
|
BackoffLimit: intToInt32(backoffLimit),
|
|
|
|
|
Completions: intToInt32(completions),
|
|
|
|
|
Completions: completions,
|
|
|
|
|
Template: corev1.PodTemplateSpec{
|
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
|
Name: name,
|
|
|
|
|