mirror of
https://github.com/truenas/charts.git
synced 2024-04-21 15:21:45 +00:00
add port tests
This commit is contained in:
@@ -10,4 +10,185 @@ tests:
|
||||
isKind:
|
||||
of: Deployment
|
||||
|
||||
#TODO: ports
|
||||
- it: should fail with named port
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
targetPort: some_name
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
documentIndex: *deploymentDoc
|
||||
errorMessage: This common library does not support named ports for targetPort. port name (main), targetPort (some_name)
|
||||
|
||||
- it: should fail without port
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
documentIndex: *deploymentDoc
|
||||
errorMessage: Port is required on enabled services. Service (main)
|
||||
|
||||
- it: should fail with invalid protocol
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
protocol: NOT_VALID
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
documentIndex: *deploymentDoc
|
||||
errorMessage: Not valid <protocol> (NOT_VALID)
|
||||
|
||||
- it: should pass with with only port set
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.containers[0].ports[0]
|
||||
value:
|
||||
name: main
|
||||
containerPort: 443
|
||||
protocol: TCP
|
||||
|
||||
- it: should pass with with port and targetPort set
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
targetPort: 8000
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.containers[0].ports[0]
|
||||
value:
|
||||
name: main
|
||||
containerPort: 8000
|
||||
protocol: TCP
|
||||
|
||||
- it: should pass with with port and targetPort and protocol set
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
protocol: TCP
|
||||
targetPort: 8000
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.containers[0].ports[0]
|
||||
value:
|
||||
name: main
|
||||
containerPort: 8000
|
||||
protocol: TCP
|
||||
|
||||
- it: should pass with with port and targetPort and protocol UDP set
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
protocol: UDP
|
||||
targetPort: 8000
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.containers[0].ports[0]
|
||||
value:
|
||||
name: main
|
||||
containerPort: 8000
|
||||
protocol: UDP
|
||||
|
||||
- it: should pass with with port and targetPort and protocol HTTP set
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
protocol: HTTP
|
||||
targetPort: 8000
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.containers[0].ports[0]
|
||||
value:
|
||||
name: main
|
||||
containerPort: 8000
|
||||
protocol: TCP
|
||||
|
||||
- it: should pass with with port and targetPort and protocol HTTPS set
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
protocol: HTTPS
|
||||
targetPort: 8000
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.containers[0].ports[0]
|
||||
value:
|
||||
name: main
|
||||
containerPort: 8000
|
||||
protocol: TCP
|
||||
|
||||
- it: should pass with with multiple port and targetPort and protocol set
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
ports:
|
||||
main:
|
||||
port: 443
|
||||
protocol: HTTP
|
||||
targetPort: 8000
|
||||
secondary:
|
||||
enabled: true
|
||||
ports:
|
||||
secondary:
|
||||
enabled: true
|
||||
port: 444
|
||||
protocol: TCP
|
||||
targetPort: 8001
|
||||
third:
|
||||
enabled: true
|
||||
ports:
|
||||
third:
|
||||
enabled: true
|
||||
port: 445
|
||||
protocol: UDP
|
||||
targetPort: 8002
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.template.spec.containers[0].ports
|
||||
value:
|
||||
- name: main
|
||||
containerPort: 8000
|
||||
protocol: TCP
|
||||
- name: secondary
|
||||
containerPort: 8001
|
||||
protocol: TCP
|
||||
- name: third
|
||||
containerPort: 8002
|
||||
protocol: UDP
|
||||
|
||||
@@ -16,20 +16,20 @@ ports:
|
||||
{{- range $_ := $ports }}
|
||||
{{- if .enabled }}
|
||||
- name: {{ tpl .name $ }}
|
||||
{{- if and .targetPort (kindIs "string" .targetPort) }}
|
||||
{{- fail (printf "This common library does not support named ports for targetPort. (port name: %s, targetPort: %s)" .name .targetPort) }}
|
||||
{{- end }}
|
||||
{{- if not .port }}
|
||||
{{- fail (printf "Port is required on enabled services. Service: (%s)" .name) }}
|
||||
{{- fail (printf "Port is required on enabled services. Service (%s)" .name) }}
|
||||
{{- end }}
|
||||
{{- if and .targetPort (kindIs "string" .targetPort) }}
|
||||
{{- fail (printf "This common library does not support named ports for targetPort. port name (%s), targetPort (%s)" .name .targetPort) }}
|
||||
{{- end }}
|
||||
containerPort: {{ default .port .targetPort }}
|
||||
{{- with .protocol }}
|
||||
{{- if or (eq (. | upper) "HTTP") (eq (. | upper) "HTTPS") (eq (. | upper) "TCP") }}
|
||||
protocol: TCP
|
||||
{{- else if (eq (. | upper) "UDP") }}
|
||||
protocol: {{ . }}
|
||||
protocol: UDP
|
||||
{{- else }}
|
||||
{{- fail (printf "Not valid <protocol> (protocl: %s)" .) }}
|
||||
{{- fail (printf "Not valid <protocol> (%s)" .) }}
|
||||
{{- end }}
|
||||
{{- else }} {{/* If no protocol is given, default to TCP */}}
|
||||
protocol: TCP
|
||||
|
||||
@@ -168,7 +168,7 @@ service:
|
||||
enabled: true
|
||||
# enabled: false
|
||||
# -- The port number (Default port is required if enabled: true)
|
||||
port: 2
|
||||
port: 999999
|
||||
# -- Port protocol.
|
||||
# Support values are `HTTP`, `HTTPS`, `TCP` and `UDP`.
|
||||
# HTTPS and HTTPS spawn a TCP service and get used for internal URL and name generation
|
||||
|
||||
Reference in New Issue
Block a user