test/unit: UI service
This commit is contained in:
parent
5e1e1b1bf6
commit
489a396b4c
3 changed files with 101 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
|||
# the agent is installed locally on the node and the NODE_IP should be used.
|
||||
# If the node can't run a Consul agent, then this service can be used to
|
||||
# communicate directly to a server agent.
|
||||
{{- if (and (default .Values.server.enabled .Values.global.enabled) (default .Values.ui.enabled .Values.global.enabled) (default .Values.ui.service .Values.global.enabled)) }}
|
||||
{{- if (and (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) (or (and (ne (.Values.ui.enabled | toString) "-") .Values.ui.enabled) (and (eq (.Values.ui.enabled | toString) "-") .Values.global.enabled)) (or (and (ne (.Values.ui.service.enabled | toString) "-") .Values.ui.service.enabled) (and (eq (.Values.ui.service.enabled | toString) "-") .Values.global.enabled))) }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
|
@ -22,7 +22,7 @@ spec:
|
|||
- name: http
|
||||
port: 80
|
||||
targetPort: 8500
|
||||
{{- if .Values.ui.serviceType }}
|
||||
type: {{ .Values.ui.serviceType }}
|
||||
{{- if .Values.ui.service.type }}
|
||||
type: {{ .Values.ui.service.type }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
94
test/unit/ui-service.bats
Executable file
94
test/unit/ui-service.bats
Executable file
|
@ -0,0 +1,94 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "ui/Service: enabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'server.enabled=true' \
|
||||
--set 'ui.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: disable with server.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
--set 'server.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: disable with ui.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
--set 'ui.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: disable with ui.service.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
--set 'ui.service.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: disable with global.enabled and server.enabled on" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'server.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: no type by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.type' | tee /dev/stderr)
|
||||
[ "${actual}" = "null" ]
|
||||
}
|
||||
|
||||
@test "ui/Service: specified type" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/ui-service.yaml \
|
||||
--set 'ui.service.type=LoadBalancer' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.type' | tee /dev/stderr)
|
||||
[ "${actual}" = "LoadBalancer" ]
|
||||
}
|
|
@ -103,15 +103,16 @@ ui:
|
|||
# on the server nodes. This makes UI access via the service below (if
|
||||
# enabled) predictable rather than "any node" if you're running Consul
|
||||
# clients as well.
|
||||
enabled: null
|
||||
enabled: "-"
|
||||
|
||||
# True if you want to create a Service entry for the Consul UI.
|
||||
#
|
||||
# serviceType can be used to control the type of service created. For
|
||||
# example, setting this to "LoadBalancer" will create an external load
|
||||
# balancer (for supported K8S installations) to access the UI.
|
||||
service: true
|
||||
serviceType: null
|
||||
service:
|
||||
enabled: true
|
||||
type: null
|
||||
|
||||
test:
|
||||
image: lachlanevenson/k8s-kubectl
|
||||
|
|
Loading…
Reference in a new issue