Extended defaults for jobs.
Currently jobs will only default completions and parallelism. This adds copying labels map for pod's template as selectors, similarly how it's done in replication controller.
This commit is contained in:
@@ -192,20 +192,48 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
func TestSetDefaultJob(t *testing.T) {
|
||||
expected := &Job{
|
||||
Spec: JobSpec{
|
||||
Selector: map[string]string{"job": "selector"},
|
||||
Completions: newInt(1),
|
||||
Parallelism: newInt(2),
|
||||
},
|
||||
}
|
||||
tests := []*Job{
|
||||
{},
|
||||
// selector set explicitly, completions and parallelism - default
|
||||
{
|
||||
Spec: JobSpec{
|
||||
Selector: map[string]string{"job": "selector"},
|
||||
},
|
||||
},
|
||||
// selector from template labels, completions and parallelism - default
|
||||
{
|
||||
Spec: JobSpec{
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{"job": "selector"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
// selector from template labels, completions set explicitly, parallelism - default
|
||||
{
|
||||
Spec: JobSpec{
|
||||
Completions: newInt(1),
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{"job": "selector"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
// selector from template labels, completions - default, parallelism set explicitly
|
||||
{
|
||||
Spec: JobSpec{
|
||||
Parallelism: newInt(2),
|
||||
Template: &v1.PodTemplateSpec{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Labels: map[string]string{"job": "selector"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -223,6 +251,9 @@ func TestSetDefaultJob(t *testing.T) {
|
||||
if *got.Spec.Parallelism != *expected.Spec.Parallelism {
|
||||
t.Errorf("got different parallelism than expected: %d %d", *got.Spec.Parallelism, *expected.Spec.Parallelism)
|
||||
}
|
||||
if !reflect.DeepEqual(got.Spec.Selector, expected.Spec.Selector) {
|
||||
t.Errorf("got different selectors %#v %#v", got.Spec.Selector, expected.Spec.Selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user