mirror of
https://github.com/truenas/charts.git
synced 2026-06-17 15:38:49 +08:00
fix Endpoints typo and add externalIP tests
This commit is contained in:
@@ -261,3 +261,101 @@ tests:
|
||||
some_key1: value1
|
||||
some_key2: value2
|
||||
some_key3: value3
|
||||
|
||||
- it: should pass with labels (Endpoints)
|
||||
documentIndex: &endpointsDoc 2
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
labels:
|
||||
some_key: value
|
||||
some_key1: value1
|
||||
asserts:
|
||||
- isKind:
|
||||
of: Endpoints
|
||||
- isAPIVersion:
|
||||
of: v1
|
||||
- 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 (Endpoints)
|
||||
documentIndex: *endpointsDoc
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
some_key2: value2
|
||||
some_key3: value3
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
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 annotations (Endpoints)
|
||||
documentIndex: *endpointsDoc
|
||||
set:
|
||||
addAnnotations:
|
||||
traefik: true
|
||||
metallb: true
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
annotations:
|
||||
some_key: value
|
||||
some_key1: value1
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
some_key: value
|
||||
some_key1: value1
|
||||
|
||||
- it: should pass with global annotations (Endpoints)
|
||||
documentIndex: *endpointsDoc
|
||||
set:
|
||||
global:
|
||||
annotations:
|
||||
some_key: value
|
||||
some_key1: value1
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
some_key: value
|
||||
some_key1: value1
|
||||
|
||||
262
library/common-test/tests/service/service_test_ExternalIP.yaml
Normal file
262
library/common-test/tests/service/service_test_ExternalIP.yaml
Normal file
@@ -0,0 +1,262 @@
|
||||
suite: service test ExternalIP
|
||||
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 ExternalIP service type
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: &defaultPort
|
||||
- name: main
|
||||
port: 65535
|
||||
protocol: TCP
|
||||
targetPort: main
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
|
||||
- it: should pass with ExternalIP service type (Endpoint)
|
||||
documentIndex: &endpointDoc 2
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
asserts:
|
||||
- isKind:
|
||||
of: Endpoints
|
||||
- isAPIVersion:
|
||||
of: v1
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-common-test
|
||||
- equal:
|
||||
path: subsets[0]
|
||||
value:
|
||||
addresses:
|
||||
- 10.10.10.100
|
||||
ports:
|
||||
- port: 65535
|
||||
name: main
|
||||
|
||||
- it: should pass with ExternalIP service type with multiple ports (Endpoint)
|
||||
documentIndex: &endpointDoc 2
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
ports:
|
||||
main:
|
||||
enabled: true
|
||||
port: 65535
|
||||
main2:
|
||||
enabled: true
|
||||
port: 65534
|
||||
asserts:
|
||||
- isKind:
|
||||
of: Endpoints
|
||||
- isAPIVersion:
|
||||
of: v1
|
||||
- equal:
|
||||
path: subsets[0]
|
||||
value:
|
||||
addresses:
|
||||
- 10.10.10.100
|
||||
ports:
|
||||
- port: 65535
|
||||
name: main
|
||||
- port: 65534
|
||||
name: main2
|
||||
|
||||
- it: should pass with ExternalIP service type and externalTrafficPolicy
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
externalTrafficPolicy: Cluster
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: *defaultPort
|
||||
externalTrafficPolicy: Cluster
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
|
||||
- it: should pass with ExternalIP service type and sessionAffinity set to None
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
sessionAffinity: None
|
||||
sessionAffinityConfig:
|
||||
ClientIP:
|
||||
timeoutSeconds: 1000
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: *defaultPort
|
||||
sessionAffinity: None
|
||||
- isNull:
|
||||
path: spec.sessionAffinityConfig
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
|
||||
- it: should pass with ExternalIP service type and sessionAffinity set to ClientIP
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
sessionAffinity: ClientIP
|
||||
sessionAffinityConfig:
|
||||
clientIP:
|
||||
timeoutSeconds: 1000
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: *defaultPort
|
||||
sessionAffinity: ClientIP
|
||||
sessionAffinityConfig:
|
||||
clientIP:
|
||||
timeoutSeconds: 1000
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
|
||||
- it: should pass with ExternalIP service type and sessionAffinity set to ClientIP from tpl
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
timeout: 1000
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
sessionAffinity: ClientIP
|
||||
sessionAffinityConfig:
|
||||
clientIP:
|
||||
timeoutSeconds: 1000
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: *defaultPort
|
||||
sessionAffinity: ClientIP
|
||||
sessionAffinityConfig:
|
||||
clientIP:
|
||||
timeoutSeconds: 1000
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
|
||||
- it: should pass with ExternalIP service type and externalIPs
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
externalIPs:
|
||||
- 192.168.1.20
|
||||
- 192.168.1.21
|
||||
- 192.168.1.22
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: *defaultPort
|
||||
externalIPs:
|
||||
- 192.168.1.20
|
||||
- 192.168.1.21
|
||||
- 192.168.1.22
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
|
||||
- it: should pass with ExternalIP 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: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
externalIPs:
|
||||
- "{{ .Values.ip1 }}"
|
||||
- "{{ .Values.ip2 }}"
|
||||
- "{{ .Values.ip3 }}"
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: *defaultPort
|
||||
externalIPs:
|
||||
- 192.168.1.20
|
||||
- 192.168.1.21
|
||||
- 192.168.1.22
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
|
||||
- it: should pass with ExternalIP service type and publishNotReadyAddresses
|
||||
documentIndex: *serviceDoc
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
type: ExternalIP
|
||||
externalIP: 10.10.10.100
|
||||
publishNotReadyAddresses: true
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec
|
||||
value:
|
||||
ports: *defaultPort
|
||||
publishNotReadyAddresses: true
|
||||
- isNull:
|
||||
path: spec.selector
|
||||
- isNull:
|
||||
path: spec.type
|
||||
@@ -165,7 +165,7 @@ subsets:
|
||||
- {{ tpl . $root }}
|
||||
{{- else -}}
|
||||
{{- fail "Service type is set to ExternalIP, but no externalIP is defined." -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
ports:
|
||||
{{- range $name, $port := $svcValues.ports }}
|
||||
{{- if $port.enabled }}
|
||||
|
||||
Reference in New Issue
Block a user