Just to clarify.
- I am not talking about Helm chart best practices. I can read them by myself over here: https://helm.sh/docs/chart_best_practices/
- I am not talking about Terratest.
I am interested in Helm Test you can read more about it over here https://helm.sh/docs/chart_tests/#chart-tests .
Unfortunately, the documentation doesn't provide you a lot of information and that is partly the reason for this question.
What we have:
- We can have a test defined in a Chart by the following path
our-app/templates/tests/test-our-app.yaml
- As far as I can understand and according to documentation, it is not a unit test for chart but more like a smoke test or integration test. Documentation: "validate that your chart works as expected when it is installed". This is exactly what I need.
- In order to run the test https://helm.sh/docs/chart_tests/#steps-to-run-a-test-suite-on-a-release. We need to install our-app Chart
$ helm install our-app
and then we can test that image
$ helm test release-with-our-app
Things I would like to clarify:
Should we have two separate docker images or one for application and tests?...
a). In the case of it being single one image for both application code and test code then we are adding code for the test/tests all on that image, which makes it bigger and additionally we need to put dependencies that are required by tests on that image. To me, this solution seems to be wrong.
b). The case where we have a separate image for tests makes more sense because our app docker image is free of any unnecessary dependencies. What's more, in the second solution we don't really care about the size of the docker image with the test(s) because it is supposed to be a short-living image that shuts down when tests on it are finished.
Is my assumption correct and we should have a separate image for these tests?
In case if have two separate images, one for code another for tests. How do we marry them with each other? Does it mean that we have to pass a Build/Release number to helm test command so it is able to pull down the correct image for tests?
Also in case if we have two separate images. Should I specify the test run in a docker file for tests? for example :
CMD ["sh", "-c", "gradle test -Denvironment=$ENVIRONMENT"]
Or should it be inside chart
our-app/templates/tests/test-our-app.yaml
For example test.yaml from mysql repo:
https://github.com/helm/charts/blob/master/stable/mysql/templates/tests/test-configmap.yaml
- It looks like environments are not mentioned at all in the documentation. My question is what is the best/recommended way to pass environment name to the chart so tests know which endpoints to hit etc? Should it be Chart args How to pass dynamic arguments to a helm chart that runs a job ?