Chart Tests
Test hooks let you verify a release works after installing, run on demand with helm test.
helm test <release>A chart can ship its own tests — pods that check the release is functioning. You run them with helm test <release> after installing.
Writing a test
A test is a resource (usually a Pod) annotated with helm.sh/hook: test. It typically connects to the deployed service and exits 0 on success, non-zero on failure.
Put test files under templates/tests/ by convention.
Running
helm test my-release creates the test pods, waits for them, and reports pass or fail.
Example
# templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "{{ .Release.Name }}-test-connection"
annotations:
"helm.sh/hook": test
spec:
restartPolicy: Never
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "mychart.fullname" . }}:{{ .Values.service.port }}']When to use it
- A chart author ships a test Pod in templates/tests/ that curls the deployed service's /health endpoint so any user can run helm test after install to verify the deployment works.
- A developer runs helm test in a CI pipeline immediately after helm upgrade to confirm the new version responds correctly before marking the deploy as successful.
- A QA team uses helm test to validate a release in a shared staging environment after each PR is merged, catching regressions before they reach production.
More examples
Test pod template
Defines a test hook Pod that validates the deployed service's health endpoint; runs only when helm test is called.
# templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: {{ include "myapp.fullname" . }}-test-connection
labels:
{{- include "myapp.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
restartPolicy: Never
containers:
- name: curl
image: curlimages/curl:latest
command: ['curl', '--fail', 'http://{{ include "myapp.fullname" . }}:{{ .Values.service.port }}/health']Run chart tests
Runs all test hook Pods for the release; --logs prints the container output, useful for diagnosing test failures.
helm test my-release -n production
helm test my-release -n production --logsTest in CI after upgrade
Chains upgrade with helm test in CI: waits for the upgrade to complete, then immediately validates the release with test hooks.
helm upgrade --install my-app ./chart \
-f values-staging.yaml \
--wait --timeout 5m \
-n staging
# Validate deployment after upgrade
helm test my-app -n staging --timeout 2m
Discussion