Skip to content

Commit

Permalink
Update CSI log tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zlaticanin committed Jul 29, 2024
1 parent e775e25 commit 92ac99a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion templates/csi-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ spec:
imagePullPolicy: {{ .Values.csi.image.pullPolicy }}
args:
- --endpoint=/provider/vault.sock
- --debug={{ .Values.csi.debug }}
{{- if .Values.csi.debug }}
- --log-level=debug
{{- else }}
- --log-level={{ .Values.csi.logLevel }}
{{- end }}
{{- if .Values.csi.hmacSecretName }}
- --hmac-secret-name={{ .Values.csi.hmacSecretName }}
{{- else }}
Expand Down
27 changes: 25 additions & 2 deletions test/unit/csi-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,40 @@ load _helpers
--set "csi.enabled=true" \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].args[1]' | tee /dev/stderr)
[ "${actual}" = "--debug=false" ]
[ "${actual}" = "--log-level=info" ]

local actual=$(helm template \
--show-only templates/csi-daemonset.yaml \
--set "csi.enabled=true" \
--set "csi.logLevel=error" \
--set "csi.debug=true" \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].args[1]' | tee /dev/stderr)
[ "${actual}" = "--debug=true" ]
[ "${actual}" = "--log-level=debug" ]
}

@test "csi/daemonset: default log-level" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/csi-daemonset.yaml \
--set "csi.enabled=true" \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].args[1]' | tee /dev/stderr)
[ "${actual}" = "--log-level=info" ]
}

@test "csi/daemonset: log-level is configurable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/csi-daemonset.yaml \
--set "csi.enabled=true" \
--set "csi.logLevel=warn" \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].args[1]' | tee /dev/stderr)
[ "${actual}" = "--log-level=warn" ]
}


# HMAC secret arg
@test "csi/daemonset: HMAC secret arg is configurable" {
cd `chart_dir`
Expand Down
7 changes: 6 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,12 @@ csi:
# Number of seconds after which the probe times out.
timeoutSeconds: 3

# Enables debug logging.
# Configures the log verbosity of the injector.
# Supported log levels include: trace, debug, info, warn, error, and off
logLevel: "info"

# Deprecated, set logLevel to debug instead.
# If set to true, the logLevel will be set to debug.
debug: false

# Pass arbitrary additional arguments to vault-csi-provider.
Expand Down

0 comments on commit 92ac99a

Please sign in to comment.