test/unit: server StatefulSet
This commit is contained in:
parent
0010bd014b
commit
64f43108f7
2 changed files with 70 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
# StatefulSet to run the actual Consul server cluster.
|
# StatefulSet to run the actual Consul server cluster.
|
||||||
{{- if (default .Values.server.enabled .Values.global.enabled) }}
|
{{- if (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) }}
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: StatefulSet
|
kind: StatefulSet
|
||||||
metadata:
|
metadata:
|
||||||
|
|
69
test/unit/server-statefulset.bats
Executable file
69
test/unit/server-statefulset.bats
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load _helpers
|
||||||
|
|
||||||
|
@test "server/StatefulSet: enabled by default" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-statefulset.yaml \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/StatefulSet: enable with global.enabled false" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-statefulset.yaml \
|
||||||
|
--set 'global.enabled=false' \
|
||||||
|
--set 'server.enabled=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/StatefulSet: disable with server.enabled" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-statefulset.yaml \
|
||||||
|
--set 'server.enabled=false' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "false" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/StatefulSet: disable with global.enabled" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-statefulset.yaml \
|
||||||
|
--set 'global.enabled=false' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "false" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/StatefulSet: no updateStrategy when not updating" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-statefulset.yaml \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.updateStrategy' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "null" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/StatefulSet: updateStrategy during update" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-statefulset.yaml \
|
||||||
|
--set 'server.updatePartition=2' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.updateStrategy.type' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "RollingUpdate" ]
|
||||||
|
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-statefulset.yaml \
|
||||||
|
--set 'server.updatePartition=2' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq -r '.spec.updateStrategy.rollingUpdate.partition' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "2" ]
|
||||||
|
}
|
Loading…
Reference in a new issue