@@ -401,10 +401,11 @@ func TestMergePreset(t *testing.T) {
401401 pod * coreapi.PodSpec
402402 presets []Preset
403403
404- shouldError bool
405- numEnv int
406- numVol int
407- numVolMounts int
404+ shouldError bool
405+ numEnv int
406+ numVol int
407+ numVolMounts int
408+ numTolerations int
408409 }{
409410 {
410411 name : "one volume" ,
@@ -499,11 +500,13 @@ func TestMergePreset(t *testing.T) {
499500 Env : []coreapi.EnvVar {{Name : "baz" }},
500501 VolumeMounts : []coreapi.VolumeMount {{Name : "baz" }},
501502 Volumes : []coreapi.Volume {{Name : "qux" }},
503+ Tolerations : []coreapi.Toleration {{Key : "foo" , Operator : coreapi .TolerationOpEqual , Value : "bar" , Effect : coreapi .TaintEffectNoSchedule }},
502504 },
503505 },
504- numEnv : 1 ,
505- numVol : 1 ,
506- numVolMounts : 1 ,
506+ numEnv : 1 ,
507+ numVol : 1 ,
508+ numVolMounts : 1 ,
509+ numTolerations : 1 ,
507510 },
508511 {
509512 name : "two vm" ,
@@ -588,6 +591,17 @@ func TestMergePreset(t *testing.T) {
588591 },
589592 shouldError : true ,
590593 },
594+ {
595+ name : "duplicate tolerations" ,
596+ jobLabels : map [string ]string {"foo" : "bar" },
597+ pod : & coreapi.PodSpec {Tolerations : []coreapi.Toleration {{Key : "kubernetes.io/arch" , Operator : coreapi .TolerationOpEqual , Value : "arm64" , Effect : coreapi .TaintEffectNoSchedule }}},
598+ presets : []Preset {
599+ {
600+ Tolerations : []coreapi.Toleration {{Key : "kubernetes.io/arch" , Operator : coreapi .TolerationOpEqual , Value : "arm64" , Effect : coreapi .TaintEffectNoSchedule }},
601+ },
602+ },
603+ shouldError : true ,
604+ },
591605 }
592606 for _ , tc := range tcs {
593607 t .Run (tc .name , func (t * testing.T ) {
@@ -602,6 +616,9 @@ func TestMergePreset(t *testing.T) {
602616 if len (tc .pod .Volumes ) != tc .numVol {
603617 t .Errorf ("wrong number of volumes for podspec. Got %d, expected %d." , len (tc .pod .Volumes ), tc .numVol )
604618 }
619+ if len (tc .pod .Tolerations ) != tc .numTolerations {
620+ t .Errorf ("wrong number of tolerations for podspec. Got %d, expected %d." , len (tc .pod .Tolerations ), tc .numTolerations )
621+ }
605622 for _ , c := range tc .pod .Containers {
606623 if len (c .VolumeMounts ) != tc .numVolMounts {
607624 t .Errorf ("wrong number of volume mounts for podspec. Got %d, expected %d." , len (c .VolumeMounts ), tc .numVolMounts )
0 commit comments