test/unit: test DisruptionBudget
This commit is contained in:
parent
83fc9d981c
commit
fc30ae877e
4 changed files with 65 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
||||||
# PodDisruptionBudget to prevent degrading the server cluster through
|
# PodDisruptionBudget to prevent degrading the server cluster through
|
||||||
# voluntary cluster changes.
|
# voluntary cluster changes.
|
||||||
{{- if (and (default .Values.server.enabled .Values.global.enabled) (default .Values.server.disruptionBudget.enabled .Values.global.enabled)) }}
|
{{- if (and .Values.server.disruptionBudget.enabled (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled))) }}
|
||||||
apiVersion: policy/v1beta1
|
apiVersion: policy/v1beta1
|
||||||
kind: PodDisruptionBudget
|
kind: PodDisruptionBudget
|
||||||
metadata:
|
metadata:
|
||||||
|
|
63
test/unit/server-disruptionbudget.bats
Executable file
63
test/unit/server-disruptionbudget.bats
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load _helpers
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: enabled by default" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: enable with global.enabled false" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
--set 'global.enabled=false' \
|
||||||
|
--set 'server.enabled=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: disable with server.enabled" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
--set 'server.enabled=false' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "false" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: disable with server.disruptionBudget.enabled" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
--set 'server.disruptionBudget.enabled=false' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "false" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: disable with global.enabled" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
--set 'global.enabled=false' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq 'length > 0' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "false" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: correct maxUnavailable with n=3" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
--set 'server.replicas=3' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.maxUnavailable' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "0" ]
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ server:
|
||||||
# disruptionBudget enables the creation of a PodDisruptionBudget to
|
# disruptionBudget enables the creation of a PodDisruptionBudget to
|
||||||
# prevent voluntary degrading of the Consul server cluster.
|
# prevent voluntary degrading of the Consul server cluster.
|
||||||
disruptionBudget:
|
disruptionBudget:
|
||||||
enabled: null
|
enabled: true
|
||||||
|
|
||||||
# maxUnavailable will default to (n/2)-1 where n is the number of
|
# maxUnavailable will default to (n/2)-1 where n is the number of
|
||||||
# replicas. If you'd like a custom value, you can specify an override here.
|
# replicas. If you'd like a custom value, you can specify an override here.
|
||||||
|
|
Loading…
Reference in a new issue