diff --git a/library/common-test/tests/pod/restart_policy_test.yaml b/library/common-test/tests/pod/restart_policy_test.yaml new file mode 100644 index 0000000000..3d795fea72 --- /dev/null +++ b/library/common-test/tests/pod/restart_policy_test.yaml @@ -0,0 +1,134 @@ +suite: pod restart policy test +templates: + - common.yaml +tests: + - it: should pass with restartPolicy set from "global" + set: + podOptions: + restartPolicy: Always + controllers: + controller-name1: + enabled: true + primary: true + type: Deployment + podSpec: {} + asserts: + - documentIndex: &deploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *deploymentDoc + equal: + path: spec.template.spec.restartPolicy + value: Always + + - it: should pass with restartPolicy set from "pod" + set: + podOptions: + restartPolicy: Never + controllers: + controller-name1: + enabled: true + primary: true + type: Deployment + podSpec: + restartPolicy: Always + asserts: + - documentIndex: *deploymentDoc + isKind: + of: Deployment + - documentIndex: *deploymentDoc + equal: + path: spec.template.spec.restartPolicy + value: Always + + - it: should pass with restartPolicy set from "pod" on Jobs + set: + podOptions: + restartPolicy: Never + controllers: + controller-name1: + enabled: true + primary: true + type: Job + podSpec: + restartPolicy: OnFailure + asserts: + - documentIndex: &jobDoc 0 + isKind: + of: Job + - documentIndex: *jobDoc + equal: + path: spec.template.spec.restartPolicy + value: OnFailure + + # Failures + - it: should fail with restartPolicy to Never on Deployment + set: + podOptions: + restartPolicy: Never + controllers: + controller-name1: + enabled: true + primary: true + type: Deployment + podSpec: {} + asserts: + - failedTemplate: + errorMessage: Expected