gruntwork-io / terratest

Terratest is a Go library that makes it easier to write automated tests for your infrastructure code.

Home Page:https://terratest.gruntwork.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Whats the best way to test a library-chart template?

Mo0rBy opened this issue · comments

This is a question, not a bug or feature request. If this should be posted somewhere else, let me know and I'll just move it to wherever you tell me.

I have approximately 30 charts thats are all essentially the same, the only differences are metadata names, resources, port numbers etc.
For this reason, all these charts use a _deployment.yaml template from a library-chart. My question is, what is the best way to use TerraTest to create template tests for a library-chart template file?
I've been reading this article and successfully created some tests for myself, but it seems you can only create template tests for actual charts, not library-charts. This does make sense, as a library-chart that only contains files prefixed with an underscore (e.g. _deployment.yaml, _service.yaml) produces no output yaml manifests.

My issue is that I don't want to create a suite of tests and run it 30 different times (once for each chart) because this would mean I'm running 30 of the same tests to test the exact same thing. I'd much rather just take 2 or 3 examples with different values and then test those only, verifying that my library-chart templates are functioning as expected, and then I can trust that they work properly in each of my other charts.

As I've already said, library-charts don't produce any output yaml, so my guess is that what I'm describing isn't actually possible, and it's just wishful thinking. Thanks.

Now that I've gone through the motions of writing my tests for all my charts, I actually think it makes more sense to test each one individually rather than being able to test a template in a library chart.

The reason for this is that a chart could have other bits added to it AS WELL AS including the template from the library chart.

It also allows you to test a chart individually in an automated CI/CD pipeline when deploying the helm chart to a kubernetes cluster.