2018-09-03 15:42:25 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load _helpers
|
|
|
|
|
|
|
|
@test "server/ConfigMap: enabled by default" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2018-09-03 15:42:25 +00:00
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2019-07-31 18:26:12 +00:00
|
|
|
--set 'server.ha.enabled=true' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
|
2020-03-18 19:49:14 +00:00
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/server-config-configmap.yaml \
|
|
|
|
--set 'server.ha.enabled=true' \
|
|
|
|
--set 'server.ha.raft.enabled=true' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
|
2019-07-31 18:26:12 +00:00
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2019-07-31 18:26:12 +00:00
|
|
|
--set 'server.standalone.enabled=true' \
|
2018-09-03 15:42:25 +00:00
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
}
|
|
|
|
|
2020-03-18 19:49:14 +00:00
|
|
|
@test "server/ConfigMap: raft config disabled by default" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/server-config-configmap.yaml \
|
|
|
|
--set 'server.ha.enabled=true' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
grep "raft" | yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" != "true" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "server/ConfigMap: raft config can be enabled" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
|
|
|
--show-only templates/server-config-configmap.yaml \
|
|
|
|
--set 'server.ha.enabled=true' \
|
|
|
|
--set 'server.ha.raft.enabled=true' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
grep "raft" | yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "true" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-31 18:26:12 +00:00
|
|
|
@test "server/ConfigMap: disabled by server.dev.enabled true" {
|
2018-09-03 15:42:25 +00:00
|
|
|
cd `chart_dir`
|
2020-02-06 16:44:38 +00:00
|
|
|
local actual=$( (helm template \
|
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2019-07-31 18:26:12 +00:00
|
|
|
--set 'server.dev.enabled=true' \
|
2020-02-06 16:44:38 +00:00
|
|
|
. || echo "---") | tee /dev/stderr |
|
2018-09-03 15:42:25 +00:00
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "false" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "server/ConfigMap: disable with global.enabled" {
|
|
|
|
cd `chart_dir`
|
2020-02-06 16:44:38 +00:00
|
|
|
local actual=$( (helm template \
|
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2018-09-03 15:42:25 +00:00
|
|
|
--set 'global.enabled=false' \
|
2020-02-06 16:44:38 +00:00
|
|
|
. || echo "---") | tee /dev/stderr |
|
2018-09-03 15:42:25 +00:00
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "false" ]
|
|
|
|
}
|
|
|
|
|
2019-07-31 18:26:12 +00:00
|
|
|
@test "server/ConfigMap: standalone extraConfig is set" {
|
2018-09-03 15:42:25 +00:00
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2019-07-31 18:26:12 +00:00
|
|
|
--set 'server.standalone.enabled=true' \
|
|
|
|
--set 'server.standalone.config="{\"hello\": \"world\"}"' \
|
2018-09-03 15:42:25 +00:00
|
|
|
. | tee /dev/stderr |
|
2018-11-30 22:01:25 +00:00
|
|
|
yq '.data["extraconfig-from-values.hcl"] | match("world") | length' | tee /dev/stderr)
|
2018-09-03 15:42:25 +00:00
|
|
|
[ ! -z "${actual}" ]
|
2019-07-31 18:26:12 +00:00
|
|
|
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2019-07-31 18:26:12 +00:00
|
|
|
--set 'server.standalone.enabled=true' \
|
|
|
|
--set 'server.standalone.config="{\"foo\": \"bar\"}"' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq '.data["extraconfig-from-values.hcl"] | match("bar") | length' | tee /dev/stderr)
|
|
|
|
[ ! -z "${actual}" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "server/ConfigMap: ha extraConfig is set" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2019-07-31 18:26:12 +00:00
|
|
|
--set 'server.ha.enabled=true' \
|
|
|
|
--set 'server.ha.config="{\"hello\": \"world\"}"' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq '.data["extraconfig-from-values.hcl"] | match("world") | length' | tee /dev/stderr)
|
|
|
|
[ ! -z "${actual}" ]
|
|
|
|
|
|
|
|
local actual=$(helm template \
|
2020-02-06 16:44:38 +00:00
|
|
|
--show-only templates/server-config-configmap.yaml \
|
2019-07-31 18:26:12 +00:00
|
|
|
--set 'server.ha.enabled=true' \
|
|
|
|
--set 'server.ha.config="{\"foo\": \"bar\"}"' \
|
|
|
|
. | tee /dev/stderr |
|
|
|
|
yq '.data["extraconfig-from-values.hcl"] | match("bar") | length' | tee /dev/stderr)
|
|
|
|
[ ! -z "${actual}" ]
|
2018-09-03 15:42:25 +00:00
|
|
|
}
|
2020-02-21 16:16:33 +00:00
|
|
|
|
|
|
|
@test "server/ConfigMap: disabled by injector.externalVaultAddr" {
|
|
|
|
cd `chart_dir`
|
|
|
|
local actual=$( (helm template \
|
|
|
|
--show-only templates/server-config-configmap.yaml \
|
|
|
|
--set 'injector.externalVaultAddr=http://vault-outside' \
|
|
|
|
. || echo "---") | tee /dev/stderr |
|
|
|
|
yq 'length > 0' | tee /dev/stderr)
|
|
|
|
[ "${actual}" = "false" ]
|
|
|
|
}
|