123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- suite: pod service account name test
- templates:
- - common.yaml
- tests:
- - it: should assign serviceAccount to primary pod
- set:
- workload:
- workload-name1:
- enabled: true
- primary: true
- type: CronJob
- schedule: "* * * * *"
- podSpec:
- restartPolicy: Never
- workload-name2:
- enabled: true
- primary: false
- type: Deployment
- podSpec: {}
- serviceAccount:
- sa-name1:
- enabled: true
- primary: true
- asserts:
- - documentIndex: &cronJobDoc 1
- isKind:
- of: CronJob
- - documentIndex: *cronJobDoc
- equal:
- path: metadata.name
- value: release-name-common-test
- - documentIndex: *cronJobDoc
- equal:
- path: spec.jobTemplate.spec.template.spec.serviceAccountName
- value: release-name-common-test
- - documentIndex: &otherDeploymentDoc 2
- isKind:
- of: Deployment
- - documentIndex: *otherDeploymentDoc
- equal:
- path: spec.template.spec.serviceAccountName
- value: default
- - it: should assign serviceAccount to all pods
- set:
- workload:
- workload-name1:
- enabled: true
- primary: true
- type: Deployment
- podSpec: {}
- workload-name2:
- enabled: true
- primary: false
- type: Deployment
- podSpec: {}
- serviceAccount:
- sa-name1:
- enabled: true
- primary: true
- targetSelectAll: true
- asserts:
- - documentIndex: &deploymentDoc 1
- isKind:
- of: Deployment
- - documentIndex: *deploymentDoc
- equal:
- path: spec.template.spec.serviceAccountName
- value: release-name-common-test
- - documentIndex: &otherDeploymentDoc 2
- isKind:
- of: Deployment
- - documentIndex: *otherDeploymentDoc
- equal:
- path: spec.template.spec.serviceAccountName
- value: release-name-common-test
- - it: should assign serviceAccount to selected pods
- set:
- workload:
- workload-name1:
- enabled: true
- primary: true
- type: Deployment
- podSpec: {}
- workload-name2:
- enabled: true
- primary: false
- type: Deployment
- podSpec: {}
- serviceAccount:
- sa-name1:
- enabled: true
- primary: true
- targetSelector:
- - workload-name1
- sa-name2:
- enabled: true
- primary: false
- targetSelector:
- - workload-name2
- asserts:
- - documentIndex: &deploymentDoc 2
- isKind:
- of: Deployment
- - documentIndex: *deploymentDoc
- equal:
- path: spec.template.spec.serviceAccountName
- value: release-name-common-test
- - documentIndex: &otherDeploymentDoc 3
- isKind:
- of: Deployment
- - documentIndex: *otherDeploymentDoc
- equal:
- path: spec.template.spec.serviceAccountName
- value: release-name-common-test-sa-name2
- - it: should assign serviceAccount to selected pods
- set:
- workload:
- workload-name1:
- enabled: true
- primary: true
- type: Deployment
- podSpec: {}
- workload-name2:
- enabled: true
- primary: false
- type: Deployment
- podSpec: {}
- serviceAccount:
- sa-name1:
- enabled: true
- primary: true
- targetSelector:
- - workload-name1
- - workload-name2
- asserts:
- - documentIndex: &deploymentDoc 1
- isKind:
- of: Deployment
- - documentIndex: *deploymentDoc
- equal:
- path: spec.template.spec.serviceAccountName
- value: release-name-common-test
- - documentIndex: &otherDeploymentDoc 2
- isKind:
- of: Deployment
- - documentIndex: *otherDeploymentDoc
- equal:
- path: spec.template.spec.serviceAccountName
- value: release-name-common-test
- # Failures
- - it: should fail with more than 1 SA assigned to a pod
- set:
- workload:
- workload-name1:
- enabled: true
- primary: true
- type: Deployment
- podSpec: {}
- serviceAccount:
- sa-name1:
- enabled: true
- primary: true
- targetSelector:
- - workload-name1
- sa-name2:
- enabled: true
- targetSelector:
- - workload-name1
- asserts:
- - failedTemplate:
- errorMessage: Expected at most 1 ServiceAccount to be assigned on a pod [workload-name1]. But [2] were assigned
|