|
|
@ -4,7 +4,6 @@ Copyright The Helm Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
@ -270,44 +269,52 @@ func Test_ReadyChecker_jobReady(t *testing.T) {
|
|
|
|
job *batchv1.Job
|
|
|
|
job *batchv1.Job
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
args args
|
|
|
|
want bool
|
|
|
|
want bool
|
|
|
|
|
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job is completed",
|
|
|
|
name: "job is completed",
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 1, 0)},
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 1, 0)},
|
|
|
|
want: true,
|
|
|
|
want: true,
|
|
|
|
|
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job is incomplete",
|
|
|
|
name: "job is incomplete",
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 0)},
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 0)},
|
|
|
|
want: false,
|
|
|
|
want: false,
|
|
|
|
|
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job is failed",
|
|
|
|
name: "job is failed but within BackoffLimit",
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 1)},
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 1)},
|
|
|
|
want: false,
|
|
|
|
want: false,
|
|
|
|
|
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job is completed with retry",
|
|
|
|
name: "job is completed with retry",
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 1, 1)},
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 1, 1)},
|
|
|
|
want: true,
|
|
|
|
want: true,
|
|
|
|
|
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job is failed with retry",
|
|
|
|
name: "job is failed and beyond BackoffLimit",
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 2)},
|
|
|
|
args: args{job: newJob("foo", 1, intToInt32(1), 0, 2)},
|
|
|
|
want: false,
|
|
|
|
want: false,
|
|
|
|
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job is completed single run",
|
|
|
|
name: "job is completed single run",
|
|
|
|
args: args{job: newJob("foo", 0, intToInt32(1), 1, 0)},
|
|
|
|
args: args{job: newJob("foo", 0, intToInt32(1), 1, 0)},
|
|
|
|
want: true,
|
|
|
|
want: true,
|
|
|
|
|
|
|
|
wantErr: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job is failed single run",
|
|
|
|
name: "job is failed single run",
|
|
|
|
args: args{job: newJob("foo", 0, intToInt32(1), 0, 1)},
|
|
|
|
args: args{job: newJob("foo", 0, intToInt32(1), 0, 1)},
|
|
|
|
want: false,
|
|
|
|
want: false,
|
|
|
|
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "job with null completions",
|
|
|
|
name: "job with null completions",
|
|
|
@ -318,7 +325,12 @@ func Test_ReadyChecker_jobReady(t *testing.T) {
|
|
|
|
for _, tt := range tests {
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
c := NewReadyChecker(fake.NewSimpleClientset(), nil)
|
|
|
|
c := NewReadyChecker(fake.NewSimpleClientset(), nil)
|
|
|
|
if got := c.jobReady(tt.args.job); got != tt.want {
|
|
|
|
got, err := c.jobReady(tt.args.job)
|
|
|
|
|
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
|
|
|
|
|
t.Errorf("jobReady() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if got != tt.want {
|
|
|
|
t.Errorf("jobReady() = %v, want %v", got, tt.want)
|
|
|
|
t.Errorf("jobReady() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|