From b565a67dec9fbeba484f33882d5a8abaffa8b0c6 Mon Sep 17 00:00:00 2001 From: Sean Eagan Date: Wed, 13 May 2020 11:39:01 -0500 Subject: [PATCH] Support simulating helm test failure and timeout This is to support testing of https://github.com/fluxcd/helm-operator/issues/369. --- charts/podinfo/README.md | 2 ++ charts/podinfo/templates/tests/fail.yaml | 26 +++++++++++++++++++++ charts/podinfo/templates/tests/timeout.yaml | 26 +++++++++++++++++++++ charts/podinfo/values.yaml | 2 ++ 4 files changed, 56 insertions(+) create mode 100644 charts/podinfo/templates/tests/fail.yaml create mode 100644 charts/podinfo/templates/tests/timeout.yaml diff --git a/charts/podinfo/README.md b/charts/podinfo/README.md index 83dc784..6e6090d 100644 --- a/charts/podinfo/README.md +++ b/charts/podinfo/README.md @@ -42,6 +42,8 @@ Parameter | Default | Description `faults.error` | `false` | 1/3 chances of a random HTTP response error `faults.unhealthy` | `false` | When set, the healthy state is never reached `faults.unready` | `false` | When set, the ready state is never reached +`faults.testFail` | `false` | When set, a helm test is included which always fails +`faults.testTimeout` | `false` | When set, a helm test is included which always times out `h2c.enabled` | `false` | Allow upgrading to h2c `image.repository` | `stefanprodan/podinfo` | Image repository `image.tag` | `` | Image tag diff --git a/charts/podinfo/templates/tests/fail.yaml b/charts/podinfo/templates/tests/fail.yaml new file mode 100644 index 0000000..a66123d --- /dev/null +++ b/charts/podinfo/templates/tests/fail.yaml @@ -0,0 +1,26 @@ +{{- if .Values.faults.test }} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ template "podinfo.fullname" . }}-fault-test-{{ randAlphaNum 5 | lower }} + labels: + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app: {{ template "podinfo.name" . }} + annotations: + "helm.sh/hook": test + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded + sidecar.istio.io/inject: "false" + linkerd.io/inject: disabled + appmesh.k8s.aws/sidecarInjectorWebhook: disabled +spec: + template: + spec: + containers: + - name: fault + image: alpine:3.11 + command: ['/bin/sh'] + args: ['-c', 'exit 1'] + restartPolicy: Never +{{- end }} diff --git a/charts/podinfo/templates/tests/timeout.yaml b/charts/podinfo/templates/tests/timeout.yaml new file mode 100644 index 0000000..0edd1d5 --- /dev/null +++ b/charts/podinfo/templates/tests/timeout.yaml @@ -0,0 +1,26 @@ +{{- if .Values.faults.test }} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ template "podinfo.fullname" . }}-fault-test-{{ randAlphaNum 5 | lower }} + labels: + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }}-{{ .Chart.Version }} + app: {{ template "podinfo.name" . }} + annotations: + "helm.sh/hook": test + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded + sidecar.istio.io/inject: "false" + linkerd.io/inject: disabled + appmesh.k8s.aws/sidecarInjectorWebhook: disabled +spec: + template: + spec: + containers: + - name: fault + image: alpine:3.11 + command: ['/bin/sh'] + args: ['-c', 'while sleep 3600; do :; done'] + restartPolicy: Never +{{- end }} diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index ecfcb1b..93a37f8 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -15,6 +15,8 @@ faults: error: false unhealthy: false unready: false + testFail: false + testTimeout: false h2c: enabled: false