From 8a8eff5fc6e7802cdfc06efde133dee5b4226dd8 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Tue, 31 Jan 2023 16:06:32 +0200 Subject: [PATCH] add tests for restartpolicy --- .../tests/pod/restart_policy_test.yaml | 134 ++++++++++++++++++ .../1.0.0/templates/lib/controller/_pod.tpl | 1 + .../templates/lib/pod/_restartPolicy.tpl | 22 +++ library/common/1.0.0/values.yaml | 1 + 4 files changed, 158 insertions(+) create mode 100644 library/common-test/tests/pod/restart_policy_test.yaml create mode 100644 library/common/1.0.0/templates/lib/pod/_restartPolicy.tpl 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