update tests
This commit is contained in:
parent
b8878a696c
commit
b653371214
9 changed files with 18 additions and 579 deletions
|
@ -3,10 +3,6 @@ name_prefix() {
|
|||
printf "vault"
|
||||
}
|
||||
|
||||
ha_name_prefix() {
|
||||
printf "vault-ha"
|
||||
}
|
||||
|
||||
# helm_install installs the vault chart. This will source overridable
|
||||
# values from the "values.yaml" file in this directory. This can be set
|
||||
# by CI or other environments to do test-specific overrides. Note that its
|
||||
|
@ -33,32 +29,29 @@ helm_install_ha() {
|
|||
fi
|
||||
|
||||
helm install -f ${values} \
|
||||
--name vault-ha \
|
||||
--set 'sever.enabled=false' \
|
||||
--set 'severHA.enabled=true' \
|
||||
--name vault \
|
||||
--set 'server.enabled=false' \
|
||||
--set 'serverHA.enabled=true' \
|
||||
${BATS_TEST_DIRNAME}/../..
|
||||
}
|
||||
|
||||
# wait for consul to be running
|
||||
wait_for_running_consul() {
|
||||
POD_NAME=$1
|
||||
|
||||
check() {
|
||||
# This requests the pod and checks whether the status is running
|
||||
# and the ready state is true. If so, it outputs the name. Otherwise
|
||||
# it outputs empty. Therefore, to check for success, check for nonzero
|
||||
# string length.
|
||||
kubectl get pods $1 -o json | \
|
||||
jq -r 'select(
|
||||
kubectl get pods -l component=client -o json | \
|
||||
jq -r '.items[0] | select(
|
||||
.status.phase == "Running" and
|
||||
([ .status.conditions[] | select(.type == "Ready" and .status == "True") ] | length) == 1
|
||||
) | .metadata.namespace + "/" + .metadata.name'
|
||||
) | .metadata.name'
|
||||
}
|
||||
|
||||
for i in $(seq 30); do
|
||||
if [ -n "$(check ${POD_NAME})" ]; then
|
||||
echo "${POD_NAME} is ready."
|
||||
sleep 2
|
||||
echo "consul clients are ready."
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -66,7 +59,7 @@ wait_for_running_consul() {
|
|||
sleep 2
|
||||
done
|
||||
|
||||
echo "${POD_NAME} never became ready."
|
||||
echo "consul clients never became ready."
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
|
@ -4,40 +4,37 @@ load _helpers
|
|||
|
||||
@test "server-ha: default, comes up sealed, 1 replica" {
|
||||
helm_install_ha
|
||||
wait_for_running $(ha_name_prefix)-server-0
|
||||
wait_for_running $(name_prefix)-ha-server-0
|
||||
|
||||
# Verify installed, sealed, and 1 replica
|
||||
local sealed_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
|
||||
local sealed_status=$(kubectl exec "$(name_prefix)-ha-server-0" -- vault status -format=json |
|
||||
jq .sealed )
|
||||
[ "${sealed_status}" == "true" ]
|
||||
|
||||
local init_status=$(kubectl exec "$(name_prefix)-server-0" -- vault status -format=json |
|
||||
local init_status=$(kubectl exec "$(name_prefix)-ha-server-0" -- vault status -format=json |
|
||||
jq .initialized)
|
||||
[ "${init_status}" == "false" ]
|
||||
}
|
||||
|
||||
# setup a consul env
|
||||
setup() {
|
||||
set +e
|
||||
#if [[ "$BATS_TEST_NUMBER" -eq 1]]; then
|
||||
# ...
|
||||
#fi
|
||||
#helm delete --purge vault consul
|
||||
#kubectl delete --all pvc
|
||||
helm install https://github.com/hashicorp/consul-helm/archive/v0.3.0.tar.gz \
|
||||
--name consul \
|
||||
--set 'ui.enabled=false' \
|
||||
--set 'client.enabled=false'
|
||||
|
||||
wait_for_running_consul consul-server-0
|
||||
wait_for_running_consul
|
||||
}
|
||||
|
||||
#cleanup
|
||||
teardown() {
|
||||
# only destroy the pvc if end of all tests, so we don't destroy the consul
|
||||
# pvcs
|
||||
#if [[ "${#BATS_TEST_NAMES[@]}" -eq "$BATS_TEST_NUMBER" ]]; then
|
||||
#
|
||||
#fi
|
||||
helm delete --purge vault-ha consul
|
||||
helm delete --purge vault
|
||||
helm delete --purge consul
|
||||
kubectl delete --all pvc
|
||||
}
|
||||
|
|
|
@ -1,178 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "client/DaemonSet: enabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'client.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: disable with client.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: image defaults to global.image" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'global.image=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].image' | tee /dev/stderr)
|
||||
[ "${actual}" = "foo" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: image can be overridden with client.image" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'global.image=foo' \
|
||||
--set 'client.image=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].image' | tee /dev/stderr)
|
||||
[ "${actual}" = "bar" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: no updateStrategy when not updating" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.updateStrategy' | tee /dev/stderr)
|
||||
[ "${actual}" = "null" ]
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# extraVolumes
|
||||
|
||||
@test "client/DaemonSet: adds extra volume" {
|
||||
cd `chart_dir`
|
||||
|
||||
# Test that it defines it
|
||||
local object=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.extraVolumes[0].type=configMap' \
|
||||
--set 'client.extraVolumes[0].name=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.volumes[] | select(.name == "userconfig-foo")' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.configMap.name' | tee /dev/stderr)
|
||||
[ "${actual}" = "foo" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.configMap.secretName' | tee /dev/stderr)
|
||||
[ "${actual}" = "null" ]
|
||||
|
||||
# Test that it mounts it
|
||||
local object=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.extraVolumes[0].type=configMap' \
|
||||
--set 'client.extraVolumes[0].name=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "userconfig-foo")' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.readOnly' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.mountPath' | tee /dev/stderr)
|
||||
[ "${actual}" = "/consul/userconfig/foo" ]
|
||||
|
||||
# Doesn't load it
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.extraVolumes[0].type=configMap' \
|
||||
--set 'client.extraVolumes[0].name=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].command | map(select(test("userconfig"))) | length' | tee /dev/stderr)
|
||||
[ "${actual}" = "0" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: adds extra secret volume" {
|
||||
cd `chart_dir`
|
||||
|
||||
# Test that it defines it
|
||||
local object=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.extraVolumes[0].type=secret' \
|
||||
--set 'client.extraVolumes[0].name=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.volumes[] | select(.name == "userconfig-foo")' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.secret.name' | tee /dev/stderr)
|
||||
[ "${actual}" = "null" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.secret.secretName' | tee /dev/stderr)
|
||||
[ "${actual}" = "foo" ]
|
||||
|
||||
# Test that it mounts it
|
||||
local object=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.extraVolumes[0].type=configMap' \
|
||||
--set 'client.extraVolumes[0].name=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "userconfig-foo")' | tee /dev/stderr)
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.readOnly' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(echo $object |
|
||||
yq -r '.mountPath' | tee /dev/stderr)
|
||||
[ "${actual}" = "/consul/userconfig/foo" ]
|
||||
|
||||
# Doesn't load it
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.extraVolumes[0].type=configMap' \
|
||||
--set 'client.extraVolumes[0].name=foo' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].command | map(select(test("userconfig"))) | length' | tee /dev/stderr)
|
||||
[ "${actual}" = "0" ]
|
||||
}
|
||||
|
||||
@test "client/DaemonSet: adds loadable volume" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/client-daemonset.yaml \
|
||||
--set 'client.extraVolumes[0].type=configMap' \
|
||||
--set 'client.extraVolumes[0].name=foo' \
|
||||
--set 'client.extraVolumes[0].load=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].command | map(select(test("/consul/userconfig/foo"))) | length' | tee /dev/stderr)
|
||||
[ "${actual}" = "1" ]
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "connectInject/Deployment: disabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: disable with connectInject.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: no secretName: no tls-{cert,key}-file set" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-cert-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-key-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-auto"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Deployment: with secretName: tls-{cert,key}-file set" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.certs.secretName=foo' \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-cert-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.certs.secretName=foo' \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-key-file"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-deployment.yaml \
|
||||
--set 'connectInject.certs.secretName=foo' \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-tls-auto"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "connectInject/MutatingWebhookConfiguration: disabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-mutatingwebhook.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/MutatingWebhookConfiguration: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-mutatingwebhook.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "connectInject/MutatingWebhookConfiguration: disable with connectInject.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-mutatingwebhook.yaml \
|
||||
--set 'connectInject.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/MutatingWebhookConfiguration: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-mutatingwebhook.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "connectInject/Service: disabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-service.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Service: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-service.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'connectInject.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Service: disable with connectInject.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-service.yaml \
|
||||
--set 'connectInject.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "connectInject/Service: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/connect-inject-service.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "dns/Service: enabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/dns-service.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "dns/Service: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/dns-service.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'dns.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "dns/Service: disable with dns.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/dns-service.yaml \
|
||||
--set 'dns.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "dns/Service: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/dns-service.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
|
@ -46,8 +46,9 @@ load _helpers
|
|||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/server-config-configmap.yaml \
|
||||
--set 'server.extraConfig="{\"hello\": \"world\"}"' \
|
||||
--set 'server.config="{\"hello\": \"world\"}"' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.data["extra-from-values.json"] | match("world") | length' | tee /dev/stderr)
|
||||
yq '.data["extraconfig-from-values.hcl"] | match("world") | length' | tee /dev/stderr)
|
||||
echo "# --- actual: ${actual}" >&3
|
||||
[ ! -z "${actual}" ]
|
||||
}
|
||||
|
|
|
@ -1,151 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load _helpers
|
||||
|
||||
@test "syncCatalog/Deployment: disabled by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "syncCatalog/Deployment: enable with global.enabled false" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
||||
|
||||
@test "syncCatalog/Deployment: disable with syncCatalog.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "syncCatalog/Deployment: disable with global.enabled" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'global.enabled=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq 'length > 0' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# image
|
||||
|
||||
@test "syncCatalog/Deployment: image defaults to global.imageK8S" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'global.imageK8S=bar' \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].image' | tee /dev/stderr)
|
||||
[ "${actual}" = "bar" ]
|
||||
}
|
||||
|
||||
@test "syncCatalog/Deployment: image can be overridden with server.image" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'global.imageK8S=foo' \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
--set 'syncCatalog.image=bar' \
|
||||
. | tee /dev/stderr |
|
||||
yq -r '.spec.template.spec.containers[0].image' | tee /dev/stderr)
|
||||
[ "${actual}" = "bar" ]
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# toConsul and toK8S
|
||||
|
||||
@test "syncCatalog/Deployment: bidirectional by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-to-consul"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-to-k8s"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "syncCatalog/Deployment: to-k8s only" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
--set 'syncCatalog.toConsul=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-to-consul=false"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
--set 'syncCatalog.toConsul=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-to-k8s"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "syncCatalog/Deployment: to-consul only" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
--set 'syncCatalog.toK8S=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-to-k8s=false"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
--set 'syncCatalog.toK8S=false' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-to-consul"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# k8sPrefix
|
||||
|
||||
@test "syncCatalog/Deployment: no k8sPrefix by default" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-k8s-service-prefix"))' | tee /dev/stderr)
|
||||
[ "${actual}" = "false" ]
|
||||
}
|
||||
|
||||
@test "syncCatalog/Deployment: can specify k8sPrefix" {
|
||||
cd `chart_dir`
|
||||
local actual=$(helm template \
|
||||
-x templates/sync-catalog-deployment.yaml \
|
||||
--set 'syncCatalog.enabled=true' \
|
||||
--set 'syncCatalog.k8sPrefix=foo-' \
|
||||
. | tee /dev/stderr |
|
||||
yq '.spec.template.spec.containers[0].command | any(contains("-k8s-service-prefix=\"foo-\""))' | tee /dev/stderr)
|
||||
[ "${actual}" = "true" ]
|
||||
}
|
Loading…
Reference in a new issue