-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SHIPA-2627] omit default backoffLimit value #242
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
|
||
ketchv1 "github.com/theketchio/ketch/internal/api/v1beta1" | ||
"github.com/theketchio/ketch/internal/mocks" | ||
"github.com/theketchio/ketch/internal/utils/conversions" | ||
) | ||
|
||
func TestJobList(t *testing.T) { | ||
|
@@ -24,7 +25,7 @@ func TestJobList(t *testing.T) { | |
Parallelism: 1, | ||
Completions: 1, | ||
Suspend: false, | ||
BackoffLimit: 6, | ||
BackoffLimit: conversions.IntPtr(6), | ||
Containers: []ketchv1.Container{ | ||
{ | ||
Name: "lister", | ||
|
@@ -80,7 +81,7 @@ func TestJobListNames(t *testing.T) { | |
Parallelism: 1, | ||
Completions: 1, | ||
Suspend: false, | ||
BackoffLimit: 6, | ||
BackoffLimit: conversions.IntPtr(6), | ||
Containers: []ketchv1.Container{ | ||
{ | ||
Name: "lister", | ||
|
@@ -109,6 +110,24 @@ func TestJobListNames(t *testing.T) { | |
}, | ||
wantOut: []string{"hello"}, | ||
}, | ||
{ | ||
name: "filter", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test and the one below it share the same name, so it might be better to change the names to something like |
||
cfg: &mocks.Configuration{ | ||
CtrlClientObjects: []runtime.Object{mockJob}, | ||
DynamicClientObjects: []runtime.Object{}, | ||
}, | ||
filter: "goodbye", | ||
wantOut: []string{}, | ||
}, | ||
{ | ||
name: "filter", | ||
cfg: &mocks.Configuration{ | ||
CtrlClientObjects: []runtime.Object{mockJob}, | ||
DynamicClientObjects: []runtime.Object{}, | ||
}, | ||
filter: "hello", | ||
wantOut: []string{"hello"}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package v1beta1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added these tests just to keep coverage up. Coverage dipped in a couple packages. |
||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestCondition(t *testing.T) { | ||
tests := []struct { | ||
description string | ||
jobStatus *JobStatus | ||
conditionType ConditionType | ||
expected *Condition | ||
}{ | ||
{ | ||
description: "found", | ||
jobStatus: &JobStatus{Conditions: []Condition{{Type: "type1", Status: "active"}, {Type: "type2", Status: "failed"}}}, | ||
conditionType: ConditionType("type1"), | ||
expected: &Condition{Type: "type1", Status: "active"}, | ||
}, | ||
{ | ||
description: "not found", | ||
jobStatus: &JobStatus{Conditions: []Condition{{Type: "type1", Status: "active"}, {Type: "type2", Status: "failed"}}}, | ||
conditionType: ConditionType("complete"), | ||
expected: nil, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.description, func(t *testing.T) { | ||
res := tt.jobStatus.Condition(tt.conditionType) | ||
require.Equal(t, tt.expected, res) | ||
}) | ||
} | ||
} | ||
|
||
func TestSetCondition(t *testing.T) { | ||
now := metav1.Time{} | ||
j := &Job{ | ||
Status: JobStatus{ | ||
Conditions: []Condition{ | ||
{ | ||
Type: ConditionType("type1"), | ||
Status: "active", | ||
Message: "message-1", | ||
}, | ||
}, | ||
}, | ||
} | ||
expected := &Job{ | ||
Status: JobStatus{ | ||
Conditions: []Condition{ | ||
{ | ||
Type: ConditionType("type1"), | ||
Status: "active", | ||
Message: "message-1", | ||
}, | ||
{ | ||
Type: ConditionType("type2"), | ||
Status: "failed", | ||
Message: "message-2", | ||
LastTransitionTime: &now, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
j.SetCondition("type2", v1.ConditionStatus("failed"), "message-2", now) | ||
require.Equal(t, expected, j) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ spec: | |
{{- if $.Values.job.completions }} | ||
completions: {{ $.Values.job.completions }} | ||
{{- end }} | ||
{{- if $.Values.job.backoffLimit }} | ||
{{- if not (kindIs "invalid" $.Values.job.backoffLimit) }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
backoffLimit: {{ $.Values.job.backoffLimit }} | ||
{{- end }} | ||
{{- if $.Values.job.suspend }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this supposed to be deleted?