github.com/terraform-modules-krish/terratest@v0.29.0/examples/helm-basic-example/README.md (about) 1 # Helm Basic Example 2 3 This folder contains a minimal helm chart to demonstrate how you can use Terratest to test your helm charts. 4 5 There are two kinds of tests you can perform on a helm chart: 6 7 - Helm Template tests are tests designed to test the logic of the templates. These tests should run `helm template` with 8 various input values and parse the yaml to validate any logic embedded in the templates (e.g by reading them in using 9 client-go). Since templates are not statically typed, the goal of these tests is to promote fast cycle time 10 - Helm Integration tests are tests that are designed to deploy the infrastructure and validate that it actually 11 works as expected. If you consider the templates to be syntactic tests, these are semantic tests that validate the 12 behavior of the deployed resources. 13 14 The helm chart deploys a single replica `Deployment` resource given the container image spec and a `Service` that 15 exposes it. This chart requires the `containerImageRepo` and `containerImageTag` input values. 16 17 See the corresponding terratest code for an example of how to test this chart: 18 19 - [helm_basic_example_template_test.go](https://github.com/terraform-modules-krish/terratest/blob/v0.29.0/test/helm_basic_example_template_test.go): the template tests for this chart. 20 - [helm_basic_example_integration_test.go](https://github.com/terraform-modules-krish/terratest/blob/v0.29.0/test/helm_basic_example_integration_test.go): the integration test for this 21 chart. This test will deploy the Helm Chart and verify the `Service` endpoint. 22 23 ## Running automated tests against this Helm Chart 24 25 1. Install and setup [helm](https://docs.helm.sh/using_helm/#installing-helm) 26 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 27 1. `cd test` 28 1. `dep ensure` 29 1. `go test -v -tags helm -run TestHelmBasicExampleTemplate` for the template test 30 1. `go test -v -tags helm -run TestHelmBasicExampleDeployment` for the integration test 31 32 **NOTE**: we have build tags to differentiate kubernetes tests from non-kubernetes tests, and further differentiate helm 33 tests. This is done because minikube is heavy and can interfere with docker related tests in terratest. Similarly, helm 34 can overload the minikube system and thus interfere with the other kubernetes tests. Specifically, many of the tests 35 start to fail with `connection refused` errors from `minikube`. To avoid overloading the system, we run the kubernetes 36 tests and helm tests separately from the others. This may not be necessary if you have a sufficiently powerful machine. 37 We recommend at least 4 cores and 16GB of RAM if you want to run all the tests together.