Search code examples
kuberneteskubernetes-helm

Can you include a timeout option in a helm test template file?


I know it's possible to change the timeout option when performing helm test from the command line by using the --timeout flag on the command line.

Is there a way to specify that in the template file instead?


Solution

  • If the tests are specified as Jobs instead of Pods, a deadline can be specified in the JobSpec by setting the activeDeadlineSeconds field.

    apiVersion: batch/v1
    kind: Job
    metadata:
      name: "{{ include "helm-test-timeout.fullname" . }}-test-timeout"
      labels:
    {{ include "helm-test-timeout.labels" . | nindent 4 }}
      annotations:
        "helm.sh/hook": test-success
    spec:
      activeDeadlineSeconds: 30
      template:
        spec:
          containers:
          # The nginx container will just launch and wait
          # and cause the test to time out
          - name: nginx
            image: nginx
          restartPolicy: Never
    

    However, this deadline cannot be extended with the --timeout flag to helm test.