test/unit: connect inject Deployment

This commit is contained in:
Mitchell Hashimoto 2018-09-03 09:31:57 -07:00
parent 489a396b4c
commit fc6d86b96d
No known key found for this signature in database
GPG key ID: 744E147AA52F5B0A
3 changed files with 90 additions and 2 deletions

View file

@ -1,5 +1,5 @@
# The deployment for running the Connect sidecar injector # The deployment for running the Connect sidecar injector
{{- if (default .Values.connectInject.enabled .Values.global.enabled) }} {{- if (or (and (ne (.Values.connectInject.enabled | toString) "-") .Values.connectInject.enabled) (and (eq (.Values.connectInject.enabled | toString) "-") .Values.global.enabled)) }}
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:

View file

@ -0,0 +1,88 @@
#!/usr/bin/env bats
load _helpers
@test "connectInject/Deployment: enabled 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}" = "true" ]
}
@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 \
. | 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 \
. | 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 \
. | 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' \
. | 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' \
. | 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' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-tls-auto"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

View file

@ -66,7 +66,7 @@ client:
# ConnectInject will enable the automatic Connect sidecar injector. # ConnectInject will enable the automatic Connect sidecar injector.
connectInject: connectInject:
enabled: null enabled: "-"
image: "us.gcr.io/mitchellh-k8s/consul-k8s:latest" image: "us.gcr.io/mitchellh-k8s/consul-k8s:latest"
default: false # true will inject by default, otherwise requires annotation default: false # true will inject by default, otherwise requires annotation
caBundle: "" # empty will auto generate the bundle caBundle: "" # empty will auto generate the bundle