PageSourceSearch

https://helm.sh/assets/js/17674192.c8f042a6.js

js helm.sh collected 2026-09-24 07:27:57 UTC 7,045 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkhelm_www=self.webpackChunkhelm_www||[]).push([["37435"],{17549(e,t,s){s.r(t),s.d(t,{metadata:()=>n,default:()=>h,frontMatter:()=>r,contentTitle:()=>l,toc:()=>c,assets:()=>i});var n=JSON.parse('{"id":"topics/chart_tests","title":"Chart Tests","description":"Describes how to run and test your charts.","source":"@site/docs/topics/chart_tests.md","sourceDirName":"topics","slug":"/topics/chart_tests","permalink":"/docs/topics/chart_tests","draft":false,"unlisted":false,"editUrl":"https://github.com/helm/helm-www/blob/main/docs/topics/chart_tests.md","tags":[],"version":"current","sidebarPosition":3,"frontMatter":{"title":"Chart Tests","description":"Describes how to run and test your charts.","sidebar_position":3},"sidebar":"tutorialSidebar","previous":{"title":"Chart Hooks","permalink":"/docs/topics/charts_hooks"},"next":{"title":"Library Charts","permalink":"/docs/topics/library_charts"}}'),o=s(74848),a=s(28453);let r={title:"Chart Tests",description:"Describes how to run and test your charts.",sidebar_position:3},l,i={},c=[{value:"Example Test",id:"example-test",level:2},{value:"Steps to Run a Test Suite on a Release",id:"steps-to-run-a-test-suite-on-a-release",level:2},{value:"Notes",id:"notes",level:2}];function d(e){let t={a:"a",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,a.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.p,{children:"A chart contains a number of Kubernetes resources and components that work\ntogether. As a chart author, you may want to write some tests that validate that\nyour chart works as expected when it is installed. These tests also help the\nchart consumer understand what your chart is supposed to do."}),"\n",(0,o.jsxs)(t.p,{children:["A ",(0,o.jsx)(t.strong,{children:"test"})," in a helm chart lives under the ",(0,o.jsx)(t.code,{children:"templates/"})," directory and is a\nworkload definition (commonly a Pod or Job) that specifies a container\nwith a given command to run. The container should exit successfully (exit 0)\nfor a test to be considered a success. The definition must contain the helm\ntest hook annotation: ",(0,o.jsx)(t.code,{children:"helm.sh/hook: test"}),"."]}),"\n",(0,o.jsxs)(t.p,{children:["Note that until Helm v3, the job definition needed to contain one of these helm\ntest hook annotations: ",(0,o.jsx)(t.code,{children:"helm.sh/hook: test-success"})," or ",(0,o.jsx)(t.code,{children:"helm.sh/hook: test-failure"}),".\n",(0,o.jsx)(t.code,{children:"helm.sh/hook: test-success"})," is still accepted as a backwards-compatible\nalternative to ",(0,o.jsx)(t.code,{children:"helm.sh/hook: test"}),"."]}),"\n",(0,o.jsx)(t.p,{children:"Example tests:"}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsxs)(t.li,{children:["Validate that your configuration from the values.yaml file was properly\ninjected.\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsx)(t.li,{children:"Make sure your username and password work correctly"}),"\n",(0,o.jsx)(t.li,{children:"Make sure an incorrect username and password does not work"}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(t.li,{children:"Assert that your services are up and correctly load balancing"}),"\n",(0,o.jsx)(t.li,{children:"etc."}),"\n"]}),"\n",(0,o.jsxs)(t.p,{children:["You can run the pre-defined tests in Helm on a release using the command ",(0,o.jsx)(t.code,{children:"helm test <RELEASE_NAME>"}),". For a chart consumer, this is a great way to check that\ntheir release of a chart (or application) works as expected."]}),"\n",(0,o.jsx)(t.h2,{id:"example-test",children:"Example Test"}),"\n",(0,o.jsxs)(t.p,{children:["The ",(0,o.jsx)(t.a,{href:"/docs/helm/helm_create",children:"helm create"})," command will automatically create a number of folders and files. To try the helm test functionality, first create a demo helm chart."]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-console",children:"$ helm create demo\n"})}),"\n",(0,o.jsx)(t.p,{children:"You will now be able to see the following structure in your demo helm chart."}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{children:"demo/\n  Chart.yaml\n  values.yaml\n  charts/\n  templates/\n  templates/tests/test-connection.yaml\n"})}),"\n",(0,o.jsxs)(t.p,{children:["In ",(0,o.jsx)(t.code,{children:"demo/templates/tests/test-connection.yaml"})," you'll see a test you can try. You can see the helm test pod definition here:"]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-yaml",children:'apiVersion: v1\nkind: Pod\nmetadata:\n  name: "{{ include "demo.fullname" . }}-test-connection"\n  labels:\n    {{- include "demo.labels" . | nindent 4 }}
1\n  annotations:\n    "helm.sh/hook": test\nspec:\n  containers:\n    - name: wget\n      image: busybox\n      command: [\'wget\']\n      args: [\'{{ include "demo.fullname" . }}:{{ .Values.service.port }}\']\n  restartPolicy: Never\n\n'})}),"\n",(0,o.jsx)(t.h2,{id:"steps-to-run-a-test-suite-on-a-release",children:"Steps to Run a Test Suite on a Release"}),"\n",(0,o.jsx)(t.p,{children:"First, install the chart on your cluster to create a release. You may have to\nwait for all pods to become active; if you test immediately after this install,\nit is likely to show a transitive failure, and you will want to re-test."}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-console",children:"$ helm install demo demo --namespace default\n$ helm test demo\nNAME: demo\nLAST DEPLOYED: Mon Feb 14 20:03:16 2022\nNAMESPACE: default\nSTATUS: deployed\nREVISION: 1\nTEST SUITE:     demo-test-connection\nLast Started:   Mon Feb 14 20:35:19 2022\nLast Completed: Mon Feb 14 20:35:23 2022\nPhase:          Succeeded\n[...]\n"})}),"\n",(0,o.jsx)(t.h2,{id:"notes",children:"Notes"}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsxs)(t.li,{children:["You can define as many tests as you would like in a single yaml file or spread\nacross several yaml files in the ",(0,o.jsx)(t.code,{children:"templates/"})," directory."]}),"\n",(0,o.jsxs)(t.li,{children:["You are welcome to nest your test suite under a ",(0,o.jsx)(t.code,{children:"tests/"})," directory like\n",(0,o.jsx)(t.code,{children:"<chart-name>/templates/tests/"})," for more isolation."]}),"\n",(0,o.jsxs)(t.li,{children:["A test is a ",(0,o.jsx)(t.a,{href:"/docs/topics/charts_hooks",children:"Helm hook"}),", so annotations like\n",(0,o.jsx)(t.code,{children:"helm.sh/hook-weight"})," and ",(0,o.jsx)(t.code,{children:"helm.sh/hook-delete-policy"})," may be used with test\nresources."]}),"\n"]})]})}function h(e={}){let{wrapper:t}={...(0,a.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},28453(e,t,s){s.d(t,{R:()=>r,x:()=>l});var n=s(96540);let o={},a=n.createContext(o);function r(e){let t=n.useContext(a);return n.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),n.createElement(a.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.