https://infracost.io logo
#contributors
Title
# contributors
d

damp-ambulance-61372

07/23/2021, 12:22 PM
Two known methods for writing helm unit tests: One is using simple bash scripts to do a helm template and a grep-like operation to ensure the manifests contains changes (example https://github.com/hashicorp/consul-helm) The other is using golang and helm libraries to template the charts and ensure the resulted k8s api resource structs have the required properties. This requires more effort but is more robust and can do more complex stuff. (example https://github.com/Waterdrips/helmunit) Which one do you think is better? I think golang unit tests are overkill for most use-cases and we don't need to ensure complex functionalities but rather we simply need to ensure every variable is used and is generating expected output. So I think a method like
consul-helm
is better for us.
l

little-author-61621

07/23/2021, 1:24 PM
Looks cool, I haven't used either before but will have a look in more detail. Have you used the consul-helm method before?
There's also https://helm.sh/docs/topics/chart_tests/ we should look at, but this is more smoke tests
👀 1
d

damp-ambulance-61372

07/23/2021, 1:25 PM
Yeah I've used both before. Actually started with golang unit tests but switched to bat method like consul-helm (since golang unit tests was getting unnecessarily complex)
This helm chart tests (https://helm.sh/docs/topics/chart_tests/) is good for integration or e2e testing as they require a running k8s cluster. I think we can also have them as the next step (e.g. to run only on release tags, as they might be expensive)
l

little-author-61621

07/23/2021, 1:40 PM
Yeah that makes sense
The bash ones look pretty good actually. Have you tried these ones before? https://github.com/anikin-aa/helm-unittest
d

damp-ambulance-61372

07/23/2021, 3:06 PM
Nice. No I haven't. The last commit seems to be for 2019 and the main repo (which this is forked from) is no longer maintained. IDK if it supports helm3 or not. Maybe that won't be an issue for us and will work for us as is, or maybe we can fork it and make it work with a few tweaks. Needs a closer investigation.
l

little-author-61621

07/23/2021, 3:12 PM
This seems to be the most maintained fork: https://github.com/quintush/helm-unittest Apache Airflow switched to Python for the tests as well, more info here: https://github.com/apache/airflow/issues/11657
👍 1
7 Views