mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-05 06:26:22 -03:00
add more service tests
This commit is contained in:
@@ -17,6 +17,7 @@ tests:
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: invalid_traffic_policy
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
@@ -37,7 +38,7 @@ tests:
|
||||
main:
|
||||
sessionAffinity: ClientIP
|
||||
sessionAffinityConfig:
|
||||
ClientIP:
|
||||
clientIP:
|
||||
timeoutSeconds: -1
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
@@ -49,7 +50,7 @@ tests:
|
||||
main:
|
||||
sessionAffinity: ClientIP
|
||||
sessionAffinityConfig:
|
||||
ClientIP:
|
||||
clientIP:
|
||||
timeoutSeconds: 86401
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
@@ -250,7 +251,7 @@ tests:
|
||||
some_key1: value1
|
||||
some_key2: value2
|
||||
some_key3: value3
|
||||
# TODO: add ports etc in the below tests
|
||||
|
||||
- it: should pass with ClusterIP service type
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
@@ -259,8 +260,19 @@ tests:
|
||||
type: ClusterIP
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.type
|
||||
value: ClusterIP
|
||||
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
|
||||
@@ -271,8 +283,191 @@ tests:
|
||||
clusterIP: 172.16.0.12
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.type
|
||||
value: ClusterIP
|
||||
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.clusterIP
|
||||
value: 172.16.0.12
|
||||
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
|
||||
|
||||
@@ -56,11 +56,13 @@ spec:
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- with $svcValues.externalTrafficPolicy -}}
|
||||
{{- if not (has . (list "Cluster" "Local")) -}}
|
||||
{{- fail (printf "Invalid option (%s) for <externalTrafficPolicy>. Valid options are Cluster and Local" .) -}}
|
||||
{{- end }}
|
||||
{{- if ne $svcType "ClusterIP" -}}
|
||||
{{- with $svcValues.externalTrafficPolicy -}}
|
||||
{{- if not (has . (list "Cluster" "Local")) -}}
|
||||
{{- fail (printf "Invalid option (%s) for <externalTrafficPolicy>. Valid options are Cluster and Local" .) -}}
|
||||
{{- end }}
|
||||
externalTrafficPolicy: {{ . }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- with $svcValues.sessionAffinity }}
|
||||
{{- if not (has . (list "ClientIP" "None")) -}}
|
||||
@@ -69,15 +71,15 @@ spec:
|
||||
sessionAffinity: {{ . }}
|
||||
{{- if eq . "ClientIP" -}}
|
||||
{{- with $svcValues.sessionAffinityConfig -}}
|
||||
{{- with .ClientIP -}}
|
||||
{{- with .clientIP -}}
|
||||
{{- if hasKey . "timeoutSeconds" }}
|
||||
{{- $timeout := tpl (toString .timeoutSeconds) $root -}}
|
||||
{{- if or (lt (int $timeout) 0) (gt (int $timeout) 86400) -}}
|
||||
{{- fail (printf "Invalid value (%s) for <sessionAffinityConfig.ClientIP.timeoutSeconds>. Valid values must be with 0 and 86400" $timeout) -}}
|
||||
{{- end }}
|
||||
sessionAffinityConfig:
|
||||
ClientIP:
|
||||
timeoutSeconds: {{ $timeout }}
|
||||
sessionAffinityConfig:
|
||||
clientIP:
|
||||
timeoutSeconds: {{ $timeout }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user