SHC
SHC

Reputation: 575

HELM 3: Helm test is not working? Getting "TEST SUITE: None"

Preview: We started working on helm 3 to deploy our applications on k8s and we have come to good stage with deploying the charts successfully. However we are very new to implement tests under helm charts. For example I am deploying pdfreactor official image and i can check the web application version details either by using browser "http://172.27.1.119:31423/service/" or by "curl http://172.27.1.119:31423/service/". Now I want to write a helm test to check the same. The below is pdfreactor-test.yaml (reference link: https://helm.sh/docs/topics/chart_tests/)

apiVersion: v1
kind: Pod
metadata:
  name: "{{ .Release.Name }}-credentials-test"
  annotations:
    "helm.sh/hook": test
spec:
  containers:
    - name: {{ .Release.Name }}-credentials-test
      image: {{ .Values.image.imageName }}
      imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
      command:
        - /bin/bash
        - curl http://172.27.1.119:31423/service/

When i ran

 helm install pdfreactor <chart name> 
 helm test pdfreactor 

I got below response

NAME: pdfreactor
LAST DEPLOYED: Thu Aug 13 09:02:55 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing pdfreactor.

Below are my challenges.

  1. Need to understand what am i doing wrong?
  2. How exactly the helm test will work? Does it create a new pod and test, or does it test on existing pod?
  3. What is the purpose of giving image details in test.yaml?

Note: I have even used the default template generated with helm create.

Upvotes: 1

Views: 3192

Answers (2)

cbron
cbron

Reputation: 4044

You can only test what was templated at the last install time. If you are writing a new test you need to upgrade the chart, or uninstall and re-install, to run it.

Upvotes: 1

hilsenrat
hilsenrat

Reputation: 1420

Make sure your test configuration files reside under <chart-name>/templates/tests/ folder.

Regarding 2 and 3 - Yes, it creates a new pod, using the template you provided. The pod will run to completion, and if the Exit Code will be 0, the test is considered successful.

Upvotes: 2

Related Questions