We have a bunch of charts that define helm tests (running service checker). Unfortunately those tests are only run if triggered manually and not during a standard deploy.
We could change that by adding a postsync hook to the helmfiles running the actual tests, like:
diff --git a/helmfile.d/services/termbox/helmfile.yaml b/helmfile.d/services/termbox/helmfile.yaml index 0fc240f..812cfdb 100644 --- a/helmfile.d/services/termbox/helmfile.yaml +++ b/helmfile.d/services/termbox/helmfile.yaml @@ -32,6 +32,10 @@ templates: "{{`{{.HelmfileCommand}}`}}", "[{{ .Environment.Name }}] Ran '{{`{{.HelmfileCommand}}`}}' command on namespace '{{`{{.Release.Namespace}}`}}' for release '{{`{{.Release.Name}}`}}' .", ] + - name: "test" + events: ["postsync"] + command: "helmfile" + args: ["-e", "{{ .Environment.Name }}", "-l", "name={{`{{.Release.Name}}`}}", "test", "--cleanup"] # TODO: convert to the new release naming scheme releases:
Of course this does not come without some helm-ish salt:
- If the test fails it leaves the pod behind (cool!) but you can't run the test again because it left the pod behind (not cool!)
- When you run "helmfile test --cleanup" and the test fails - guess what - it deletes the pod so you can't look into why it failed.
I added --cleanup nevertheless for now. Maybe the logs can be grabbed from logstash then.