From 9763b22c40fe8429b905d5fccdf3a504caea2d38 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Fri, 11 Nov 2022 17:04:16 +0200 Subject: [PATCH] update test style --- .../tests/pod/deployment_annotation_test.yaml | 19 ++--- .../tests/pod/deployment_controller_test.yaml | 20 ++++-- .../tests/pod/deployment_label_test.yaml | 19 ++--- .../tests/pod/deployment_names_test.yaml | 3 +- .../tests/pod/deployment_volume_test.yaml | 72 +++++++++++++++---- 5 files changed, 95 insertions(+), 38 deletions(-) diff --git a/library/common-test/tests/pod/deployment_annotation_test.yaml b/library/common-test/tests/pod/deployment_annotation_test.yaml index da9a3632..316b1e6b 100644 --- a/library/common-test/tests/pod/deployment_annotation_test.yaml +++ b/library/common-test/tests/pod/deployment_annotation_test.yaml @@ -14,12 +14,14 @@ tests: - it: should pass with controller and global annotations set: some_key: some_value - controller.annotations: - controller_key: controller_value - controller_key2: "{{ .Values.some_key }}" - global.annotations: - global_key: global_value - global_key2: "{{ .Values.some_key }}" + controller: + annotations: + controller_key: controller_value + controller_key2: "{{ .Values.some_key }}" + global: + annotations: + global_key: global_value + global_key2: "{{ .Values.some_key }}" asserts: - equal: documentIndex: *deploymentDoc @@ -44,8 +46,9 @@ tests: - it: should pass with podAnnotations set set: some_key: some_value2 - podAnnotations.test: some_value - podAnnotations.test2: "{{ .Values.some_key }}" + podAnnotations: + test: some_value + test2: "{{ .Values.some_key }}" asserts: - equal: documentIndex: *deploymentDoc diff --git a/library/common-test/tests/pod/deployment_controller_test.yaml b/library/common-test/tests/pod/deployment_controller_test.yaml index 20691d7d..562ba0be 100644 --- a/library/common-test/tests/pod/deployment_controller_test.yaml +++ b/library/common-test/tests/pod/deployment_controller_test.yaml @@ -29,9 +29,11 @@ tests: - it: should pass with controller strategy changed and rollingUpdate strategies set set: - controller.strategy: RollingUpdate - controller.rollingUpdate.unavailable: 2 - controller.rollingUpdate.surge: 3 + controller: + strategy: RollingUpdate + rollingUpdate: + unavailable: 2 + surge: 3 asserts: - equal: documentIndex: *deploymentDoc @@ -46,14 +48,16 @@ tests: - it: should pass with controller disabled set: - controller.enabled: false + controller: + enabled: false asserts: - hasDocuments: count: 0 - it: should pass with controller strategy changed set: - controller.strategy: RollingUpdate + controller: + strategy: RollingUpdate asserts: - equal: documentIndex: *deploymentDoc @@ -65,14 +69,16 @@ tests: - it: should fail with wrong controller set: - controller.type: not_valid_controller + controller: + type: not_valid_controller asserts: - failedTemplate: errorMessage: Not a valid controller.type (not_valid_controller) - it: should fail with wrong strategy set: - controller.strategy: not_valid_strategy + controller: + strategy: not_valid_strategy asserts: - failedTemplate: errorMessage: Not a valid strategy type for Deployment (not_valid_strategy) diff --git a/library/common-test/tests/pod/deployment_label_test.yaml b/library/common-test/tests/pod/deployment_label_test.yaml index b87e194b..d208fbf2 100644 --- a/library/common-test/tests/pod/deployment_label_test.yaml +++ b/library/common-test/tests/pod/deployment_label_test.yaml @@ -31,12 +31,14 @@ tests: - it: should pass with controller and global labels set: some_key: some_value - controller.labels: - controller_key: controller_value - controller_key2: "{{ .Values.some_key }}" - global.labels: - global_key: global_value - global_key2: "{{ .Values.some_key }}" + controller: + labels: + controller_key: controller_value + controller_key2: "{{ .Values.some_key }}" + global: + labels: + global_key: global_value + global_key2: "{{ .Values.some_key }}" asserts: - equal: documentIndex: *deploymentDoc @@ -58,8 +60,9 @@ tests: - it: should pass with podLabels set set: some_key: some_value2 - podLabels.test: some_value - podLabels.test2: "{{ .Values.some_key }}" + podLabels: + test: some_value + test2: "{{ .Values.some_key }}" asserts: - equal: documentIndex: *deploymentDoc diff --git a/library/common-test/tests/pod/deployment_names_test.yaml b/library/common-test/tests/pod/deployment_names_test.yaml index ae03ee0e..c90882d2 100644 --- a/library/common-test/tests/pod/deployment_names_test.yaml +++ b/library/common-test/tests/pod/deployment_names_test.yaml @@ -24,7 +24,8 @@ tests: - it: should pass with global.nameOverride set: nameOverride: overrodeName - global.nameOverride: globalOverrodeName + global: + nameOverride: globalOverrodeName asserts: - equal: documentIndex: *deploymentDoc diff --git a/library/common-test/tests/pod/deployment_volume_test.yaml b/library/common-test/tests/pod/deployment_volume_test.yaml index f8f0de9a..6d211af6 100644 --- a/library/common-test/tests/pod/deployment_volume_test.yaml +++ b/library/common-test/tests/pod/deployment_volume_test.yaml @@ -141,54 +141,98 @@ tests: - it: should fail with wrong persistence type set: - persistence.some_volume.type: not_valid_persistence - persistence.some_volume.enabled: true + persistence: + some_volume: + type: not_valid_persistence + enabled: true asserts: - failedTemplate: errorMessage: Not a valid persistence.type (not_valid_persistence) - it: should fail with not set objectName on configMaps set: - persistence.some_volume.type: configMap - persistence.some_volume.enabled: true + persistence: + some_volume: + type: configMap + enabled: true asserts: - failedTemplate: errorMessage: objectName not set for persistence item some_volume - it: should fail with not set objectName on secrets set: - persistence.some_volume.type: secret - persistence.some_volume.enabled: true + persistence: + some_volume: + type: secret + enabled: true asserts: - failedTemplate: errorMessage: objectName not set for persistence item some_volume - it: should fail with not set path on hostPath set: - persistence.some_volume.type: hostPath - persistence.some_volume.enabled: true + persistence: + some_volume: + type: hostPath + enabled: true asserts: - failedTemplate: errorMessage: hostPath not set on item some_volume - it: should fail with not set server on nfs set: - persistence.some_volume.type: nfs - persistence.some_volume.enabled: true - persistence.some_volume.path: some_path + persistence: + some_volume: + type: nfs + enabled: true + path: some_path asserts: - failedTemplate: errorMessage: NFS Server not set on item some_volume - it: should fail with not set path on nfs set: - persistence.some_volume.type: nfs - persistence.some_volume.enabled: true - persistence.some_volume.server: some_server + persistence: + some_volume: + type: nfs + enabled: true + server: some_server asserts: - failedTemplate: errorMessage: NFS Path not set on item some_volume + - it: should fail with not set objectName on secret + set: + persistence: + some_volume: + type: secret + enabled: true + asserts: + - failedTemplate: + errorMessage: objectName not set for persistence item some_volume + + - it: should fail with not set objectName on configmap + set: + persistence: + some_volume: + type: configMap + enabled: true + asserts: + - failedTemplate: + errorMessage: objectName not set for persistence item some_volume + + - it: should pass with added configmap + set: + persistence: + some_volume: + type: configMap + enabled: true + objectName: some_name + asserts: + - failedTemplate: + errorMessage: objectName not set for persistence item some_volume + + # TODO: configmap # TODO: secret # TODO: PVC