From 5e1e1b1bf63f7be1e29c8c15a03e91c21129edb6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 3 Sep 2018 09:08:57 -0700 Subject: [PATCH] test/unit: client DaemonSet --- templates/client-daemonset.yaml | 2 +- test/unit/client-daemonset.yaml | 52 +++++++++++++++++++++++++++++++++ values.yaml | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100755 test/unit/client-daemonset.yaml diff --git a/templates/client-daemonset.yaml b/templates/client-daemonset.yaml index e363430..a55b1d9 100644 --- a/templates/client-daemonset.yaml +++ b/templates/client-daemonset.yaml @@ -1,5 +1,5 @@ # DaemonSet to run the Consul clients on every node. -{{- if (default .Values.client.enabled .Values.global.enabled) }} +{{- if (or (and (ne (.Values.client.enabled | toString) "-") .Values.client.enabled) (and (eq (.Values.client.enabled | toString) "-") .Values.global.enabled)) }} apiVersion: apps/v1 kind: DaemonSet metadata: diff --git a/test/unit/client-daemonset.yaml b/test/unit/client-daemonset.yaml new file mode 100755 index 0000000..0692ec8 --- /dev/null +++ b/test/unit/client-daemonset.yaml @@ -0,0 +1,52 @@ +#!/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: 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" ] +} diff --git a/values.yaml b/values.yaml index 1b31abc..192fdf1 100644 --- a/values.yaml +++ b/values.yaml @@ -60,7 +60,7 @@ server: # within the Kube cluster. The current deployment model follows a traditional # DC where a single agent is deployed per node. client: - enabled: null + enabled: "-" image: "consul:1.2.2" join: null