From a37c889af9e1e1d237f3fb83fcbecb1165f65fd7 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Mon, 28 Nov 2022 14:07:08 +0200 Subject: [PATCH] split tests --- .../tests/service/service_test.yaml | 220 -------- .../tests/service/service_test_clusterip.yaml | 282 ++++++++++ .../tests/service/service_test_nodeport.yaml | 513 ++++++++++++++++++ 3 files changed, 795 insertions(+), 220 deletions(-) create mode 100644 library/common-test/tests/service/service_test_clusterip.yaml create mode 100644 library/common-test/tests/service/service_test_nodeport.yaml diff --git a/library/common-test/tests/service/service_test.yaml b/library/common-test/tests/service/service_test.yaml index 40789dd16f..ea8bd6c259 100644 --- a/library/common-test/tests/service/service_test.yaml +++ b/library/common-test/tests/service/service_test.yaml @@ -251,223 +251,3 @@ tests: some_key1: value1 some_key2: value2 some_key3: value3 - - - it: should pass with ClusterIP service type - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: &defaultPort - - name: main - port: 65535 - protocol: TCP - targetPort: main - selector: &defaultSelector - app: common-test - app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: common-test - release: RELEASE-NAME - - - it: should pass with ClusterIP service type and clusterIP set - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - clusterIP: 172.16.0.12 - asserts: - - equal: - path: spec - value: - type: ClusterIP - clusterIP: 172.16.0.12 - ports: *defaultPort - selector: *defaultSelector - - - it: should pass with ClusterIP service type and externalTrafficPolicy - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - externalTrafficPolicy: Cluster - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - - isNull: - path: spec.externalTrafficPolicy - - - it: should pass with ClusterIP service type and sessionAffinity set to None - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - sessionAffinity: None - sessionAffinityConfig: - ClientIP: - timeoutSeconds: 1000 - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - sessionAffinity: None - - isNull: - path: spec.sessionAffinityConfig - - - it: should pass with ClusterIP service type and sessionAffinity set to ClientIP - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - sessionAffinity: ClientIP - sessionAffinityConfig: - clientIP: - timeoutSeconds: 1000 - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - sessionAffinity: ClientIP - sessionAffinityConfig: - clientIP: - timeoutSeconds: 1000 - - - it: should pass with ClusterIP service type and sessionAffinity set to ClientIP from tpl - documentIndex: *serviceDoc - set: - timeout: 1000 - service: - main: - type: ClusterIP - sessionAffinity: ClientIP - sessionAffinityConfig: - clientIP: - timeoutSeconds: 1000 - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - sessionAffinity: ClientIP - sessionAffinityConfig: - clientIP: - timeoutSeconds: 1000 - - - it: should pass with ClusterIP service type and externalIPs - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - externalIPs: - - 192.168.1.20 - - 192.168.1.21 - - 192.168.1.22 - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - externalIPs: - - 192.168.1.20 - - 192.168.1.21 - - 192.168.1.22 - - - it: should pass with ClusterIP service type and externalIPs from tpl - documentIndex: *serviceDoc - set: - ip1: 192.168.1.20 - ip2: 192.168.1.21 - ip3: 192.168.1.22 - service: - main: - type: ClusterIP - externalIPs: - - "{{ .Values.ip1 }}" - - "{{ .Values.ip2 }}" - - "{{ .Values.ip3 }}" - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - externalIPs: - - 192.168.1.20 - - 192.168.1.21 - - 192.168.1.22 - - - it: should pass with ClusterIP service type and publishNotReadyAddresses - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - publishNotReadyAddresses: true - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - publishNotReadyAddresses: true - - - it: should pass with ClusterIP service type and ipFamilyPolicy - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - ipFamilyPolicy: SingleStack - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - ipFamilyPolicy: SingleStack - - - it: should pass with ClusterIP service type and ipFamilies - documentIndex: *serviceDoc - set: - service: - main: - type: ClusterIP - ipFamilies: - - IPv6 - - IPv4 - asserts: - - equal: - path: spec - value: - type: ClusterIP - ports: *defaultPort - selector: *defaultSelector - ipFamilies: - - IPv6 - - IPv4 diff --git a/library/common-test/tests/service/service_test_clusterip.yaml b/library/common-test/tests/service/service_test_clusterip.yaml new file mode 100644 index 0000000000..679ed29372 --- /dev/null +++ b/library/common-test/tests/service/service_test_clusterip.yaml @@ -0,0 +1,282 @@ + +suite: service test clusterIP +templates: + - common.yaml +chart: + appVersion: &appVer v1.2.3 +tests: + - it: should pass with default values + documentIndex: &deploymentDoc 0 + asserts: + - hasDocuments: + count: 2 + - isKind: + of: Deployment + + - it: should pass with correct apiVersion + documentIndex: &serviceDoc 1 + asserts: + - isKind: + of: Service + - isAPIVersion: + of: v1 + + - it: should pass with ClusterIP service type + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: &defaultPort + - name: main + port: 65535 + protocol: TCP + targetPort: main + selector: &defaultSelector + app: common-test + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: common-test + release: RELEASE-NAME + + - it: should pass with ClusterIP service type and clusterIP set + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + clusterIP: 172.16.0.12 + asserts: + - equal: + path: spec + value: + type: ClusterIP + clusterIP: 172.16.0.12 + ports: *defaultPort + selector: *defaultSelector + + - it: should pass with ClusterIP service type and externalTrafficPolicy + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + externalTrafficPolicy: Cluster + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + - isNull: + path: spec.externalTrafficPolicy + + - it: should pass with ClusterIP service type and sessionAffinity set to None + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + sessionAffinity: None + sessionAffinityConfig: + ClientIP: + timeoutSeconds: 1000 + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + sessionAffinity: None + - isNull: + path: spec.sessionAffinityConfig + + - it: should pass with ClusterIP service type and sessionAffinity set to ClientIP + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + sessionAffinity: ClientIP + sessionAffinityConfig: + clientIP: + timeoutSeconds: 1000 + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + sessionAffinity: ClientIP + sessionAffinityConfig: + clientIP: + timeoutSeconds: 1000 + + - it: should pass with ClusterIP service type and sessionAffinity set to ClientIP from tpl + documentIndex: *serviceDoc + set: + timeout: 1000 + service: + main: + type: ClusterIP + sessionAffinity: ClientIP + sessionAffinityConfig: + clientIP: + timeoutSeconds: 1000 + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + sessionAffinity: ClientIP + sessionAffinityConfig: + clientIP: + timeoutSeconds: 1000 + + - it: should pass with ClusterIP service type and externalIPs + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + externalIPs: + - 192.168.1.20 + - 192.168.1.21 + - 192.168.1.22 + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + externalIPs: + - 192.168.1.20 + - 192.168.1.21 + - 192.168.1.22 + + - it: should pass with ClusterIP service type and externalIPs from tpl + documentIndex: *serviceDoc + set: + ip1: 192.168.1.20 + ip2: 192.168.1.21 + ip3: 192.168.1.22 + service: + main: + type: ClusterIP + externalIPs: + - "{{ .Values.ip1 }}" + - "{{ .Values.ip2 }}" + - "{{ .Values.ip3 }}" + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + externalIPs: + - 192.168.1.20 + - 192.168.1.21 + - 192.168.1.22 + + - it: should pass with ClusterIP service type and publishNotReadyAddresses + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + publishNotReadyAddresses: true + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + publishNotReadyAddresses: true + + - it: should pass with ClusterIP service type and ipFamilyPolicy + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + ipFamilyPolicy: SingleStack + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + ipFamilyPolicy: SingleStack + + - it: should pass with ClusterIP service type and ipFamilies + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + ipFamilies: + - IPv6 + - IPv4 + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: *defaultSelector + ipFamilies: + - IPv6 + - IPv4 + + - it: should pass with ClusterIP service type and custom selector + documentIndex: *serviceDoc + set: + service: + main: + type: ClusterIP + selector: + some_key: some_value + some_key1: some_value1 + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: + some_key: some_value + some_key1: some_value1 + + - it: should pass with ClusterIP service type and custom selector from tpl + documentIndex: *serviceDoc + set: + k1: some_value + k2: some_value1 + service: + main: + type: ClusterIP + selector: + some_key: "{{ .Values.k1 }}" + some_key1: "{{ .Values.k2 }}" + asserts: + - equal: + path: spec + value: + type: ClusterIP + ports: *defaultPort + selector: + some_key: some_value + some_key1: some_value1 diff --git a/library/common-test/tests/service/service_test_nodeport.yaml b/library/common-test/tests/service/service_test_nodeport.yaml new file mode 100644 index 0000000000..64b70534cc --- /dev/null +++ b/library/common-test/tests/service/service_test_nodeport.yaml @@ -0,0 +1,513 @@ + +# suite: service test nodePort +# templates: +# - common.yaml +# chart: +# appVersion: &appVer v1.2.3 +# tests: +# - it: should pass with default values +# documentIndex: &deploymentDoc 0 +# asserts: +# - hasDocuments: +# count: 2 +# - isKind: +# of: Deployment + +# - it: should fail with invalid externalTrafficPolicy +# set: +# service: +# main: +# type: LoadBalancer +# externalTrafficPolicy: invalid_traffic_policy +# asserts: +# - failedTemplate: +# errorMessage: Invalid option (invalid_traffic_policy) for . Valid options are Cluster and Local + +# - it: should fail with invalid sessionAffinity +# set: +# service: +# main: +# sessionAffinity: invalid_affinity +# asserts: +# - failedTemplate: +# errorMessage: Invalid option (invalid_affinity). Valid options are ClientIP and None + +# - it: should fail with invalid timeoutSeconds in sessionAffinityConfig negative +# set: +# service: +# main: +# sessionAffinity: ClientIP +# sessionAffinityConfig: +# clientIP: +# timeoutSeconds: -1 +# asserts: +# - failedTemplate: +# errorMessage: Invalid value (-1) for . Valid values must be with 0 and 86400 + +# - it: should fail with invalid timeoutSeconds in sessionAffinityConfig too high +# set: +# service: +# main: +# sessionAffinity: ClientIP +# sessionAffinityConfig: +# clientIP: +# timeoutSeconds: 86401 +# asserts: +# - failedTemplate: +# errorMessage: Invalid value (86401) for . Valid values must be with 0 and 86400 + +# - it: should fail with invalid ipFamilyPolicy +# set: +# service: +# main: +# ipFamilyPolicy: invalid_fam_policy +# asserts: +# - failedTemplate: +# errorMessage: Invalid option (invalid_fam_policy) for . Valid options are SingleStack, PreferDualStack, RequireDualStack + +# - it: should fail with invalid ipFamily +# set: +# service: +# main: +# ipFamilies: +# - invalid_family +# asserts: +# - failedTemplate: +# errorMessage: Invalid option (invalid_family) for . Valid options are IPv4 and IPv6 + +# - it: should fail with externalIP type but no externalIP defined +# set: +# service: +# main: +# type: ExternalIP +# externalIP: [] +# asserts: +# - failedTemplate: +# errorMessage: Service type is set to ExternalIP, but no externalIP is defined. + +# - it: should pass with correct apiVersion +# documentIndex: &serviceDoc 1 +# asserts: +# - isKind: +# of: Service +# - isAPIVersion: +# of: v1 + +# - it: should pass with correct name +# documentIndex: *serviceDoc +# asserts: +# - equal: +# path: metadata.name +# value: RELEASE-NAME-common-test + +# - it: should pass with nameOverride on other service +# documentIndex: &otherServiceDoc 2 +# set: +# service: +# other: +# enabled: true +# nameOverride: something +# ports: +# other: +# enabled: true +# port: 80 +# asserts: +# - equal: +# path: metadata.name +# value: RELEASE-NAME-common-test-something + +# - it: should pass with addAnnotations set to true +# documentIndex: *serviceDoc +# set: +# addAnnotations: +# traefik: true +# metallb: true +# service: +# main: +# type: LoadBalancer +# ports: +# main: +# protocol: HTTPS +# asserts: +# - equal: +# path: metadata.annotations +# value: +# traefik.ingress.kubernetes.io/service.serversscheme: https +# metallb.universe.tf/allow-shared-ip: RELEASE-NAME-common-test + +# - it: should pass with addAnnotations set to false +# documentIndex: *serviceDoc +# set: +# addAnnotations: +# traefik: false +# metallb: false +# service: +# main: +# type: LoadBalancer +# ports: +# main: +# protocol: HTTPS +# asserts: +# - isNull: +# path: metadata.annotations + +# - it: should pass with addAnnotations set to true and annotations +# documentIndex: *serviceDoc +# set: +# addAnnotations: +# traefik: true +# metallb: true +# service: +# main: +# type: LoadBalancer +# annotations: +# some_key: value +# some_key1: value1 +# ports: +# main: +# protocol: HTTPS +# asserts: +# - equal: +# path: metadata.annotations +# value: +# traefik.ingress.kubernetes.io/service.serversscheme: https +# metallb.universe.tf/allow-shared-ip: RELEASE-NAME-common-test +# some_key: value +# some_key1: value1 + +# - it: should pass with addAnnotations set to true and global annotations +# documentIndex: *serviceDoc +# set: +# global: +# annotations: +# some_key: value +# some_key1: value1 +# addAnnotations: +# traefik: true +# metallb: true +# service: +# main: +# type: LoadBalancer +# ports: +# main: +# protocol: HTTPS +# asserts: +# - equal: +# path: metadata.annotations +# value: +# traefik.ingress.kubernetes.io/service.serversscheme: https +# metallb.universe.tf/allow-shared-ip: RELEASE-NAME-common-test +# some_key: value +# some_key1: value1 + +# - it: should pass with labels +# documentIndex: *serviceDoc +# set: +# service: +# main: +# labels: +# some_key: value +# some_key1: value1 +# asserts: +# - equal: +# path: metadata.labels +# value: +# app: common-test +# app.kubernetes.io/instance: RELEASE-NAME +# app.kubernetes.io/managed-by: Helm +# app.kubernetes.io/name: common-test +# app.kubernetes.io/version: *appVer +# helm-revision: "0" +# helm.sh/chart: common-test-1.0.0 +# release: RELEASE-NAME +# some_key: value +# some_key1: value1 + +# - it: should pass with labels and global labels +# documentIndex: *serviceDoc +# set: +# global: +# labels: +# some_key2: value2 +# some_key3: value3 +# service: +# main: +# labels: +# some_key: value +# some_key1: value1 +# asserts: +# - equal: +# path: metadata.labels +# value: +# app: common-test +# app.kubernetes.io/instance: RELEASE-NAME +# app.kubernetes.io/managed-by: Helm +# app.kubernetes.io/name: common-test +# app.kubernetes.io/version: *appVer +# helm-revision: "0" +# helm.sh/chart: common-test-1.0.0 +# release: RELEASE-NAME +# some_key: value +# some_key1: value1 +# some_key2: value2 +# some_key3: value3 + +# - it: should pass with ClusterIP service type +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: &defaultPort +# - name: main +# port: 65535 +# protocol: TCP +# targetPort: main +# selector: &defaultSelector +# app: common-test +# app.kubernetes.io/instance: RELEASE-NAME +# app.kubernetes.io/name: common-test +# release: RELEASE-NAME + +# - it: should pass with ClusterIP service type and clusterIP set +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# clusterIP: 172.16.0.12 +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# clusterIP: 172.16.0.12 +# ports: *defaultPort +# selector: *defaultSelector + +# - it: should pass with ClusterIP service type and externalTrafficPolicy +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# externalTrafficPolicy: Cluster +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# - isNull: +# path: spec.externalTrafficPolicy + +# - it: should pass with ClusterIP service type and sessionAffinity set to None +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# sessionAffinity: None +# sessionAffinityConfig: +# ClientIP: +# timeoutSeconds: 1000 +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# sessionAffinity: None +# - isNull: +# path: spec.sessionAffinityConfig + +# - it: should pass with ClusterIP service type and sessionAffinity set to ClientIP +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# sessionAffinity: ClientIP +# sessionAffinityConfig: +# clientIP: +# timeoutSeconds: 1000 +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# sessionAffinity: ClientIP +# sessionAffinityConfig: +# clientIP: +# timeoutSeconds: 1000 + +# - it: should pass with ClusterIP service type and sessionAffinity set to ClientIP from tpl +# documentIndex: *serviceDoc +# set: +# timeout: 1000 +# service: +# main: +# type: ClusterIP +# sessionAffinity: ClientIP +# sessionAffinityConfig: +# clientIP: +# timeoutSeconds: 1000 +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# sessionAffinity: ClientIP +# sessionAffinityConfig: +# clientIP: +# timeoutSeconds: 1000 + +# - it: should pass with ClusterIP service type and externalIPs +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# externalIPs: +# - 192.168.1.20 +# - 192.168.1.21 +# - 192.168.1.22 +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# externalIPs: +# - 192.168.1.20 +# - 192.168.1.21 +# - 192.168.1.22 + +# - it: should pass with ClusterIP service type and externalIPs from tpl +# documentIndex: *serviceDoc +# set: +# ip1: 192.168.1.20 +# ip2: 192.168.1.21 +# ip3: 192.168.1.22 +# service: +# main: +# type: ClusterIP +# externalIPs: +# - "{{ .Values.ip1 }}" +# - "{{ .Values.ip2 }}" +# - "{{ .Values.ip3 }}" +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# externalIPs: +# - 192.168.1.20 +# - 192.168.1.21 +# - 192.168.1.22 + +# - it: should pass with ClusterIP service type and publishNotReadyAddresses +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# publishNotReadyAddresses: true +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# publishNotReadyAddresses: true + +# - it: should pass with ClusterIP service type and ipFamilyPolicy +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# ipFamilyPolicy: SingleStack +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# ipFamilyPolicy: SingleStack + +# - it: should pass with ClusterIP service type and ipFamilies +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# ipFamilies: +# - IPv6 +# - IPv4 +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: *defaultSelector +# ipFamilies: +# - IPv6 +# - IPv4 + +# - it: should pass with ClusterIP service type and custom selector +# documentIndex: *serviceDoc +# set: +# service: +# main: +# type: ClusterIP +# selector: +# some_key: some_value +# some_key1: some_value1 +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: +# some_key: some_value +# some_key1: some_value1 + +# - it: should pass with ClusterIP service type and custom selector from tpl +# documentIndex: *serviceDoc +# set: +# k1: some_value +# k2: some_value1 +# service: +# main: +# type: ClusterIP +# selector: +# some_key: "{{ .Values.k1 }}" +# some_key1: "{{ .Values.k2 }}" +# asserts: +# - equal: +# path: spec +# value: +# type: ClusterIP +# ports: *defaultPort +# selector: +# some_key: some_value +# some_key1: some_value1