<p>Just to clarify.</p>

<ol>
<li>I am not talking about Helm chart best practices. I can read them by myself over here: <a href="https://helm.sh/docs/chart_best_practices/" rel="noreferrer">https://helm.sh/docs/chart_best_practices/</a></li>
<li>I am not talking about Terratest. </li>
</ol>

<p>I am interested in Helm Test you can read more about it over here <a href="https://helm.sh/docs/chart_tests/#chart-tests" rel="noreferrer">https://helm.sh/docs/chart_tests/#chart-tests</a> .</p>

<p>Unfortunately, the documentation doesn't provide you a lot of information and that is partly the reason for this question.</p>

<p>What we have:  </p>

<ol>
<li>We can have a test defined in a Chart by the following path </li>
</ol>

<blockquote>
  <p>our-app/templates/tests/test-our-app.yaml</p>
</blockquote>

<ol start="2">
<li>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.</li>
<li>In order to run the test <a href="https://helm.sh/docs/chart_tests/#steps-to-run-a-test-suite-on-a-release" rel="noreferrer">https://helm.sh/docs/chart_tests/#steps-to-run-a-test-suite-on-a-release</a>.
We need to install our-app Chart</li>
</ol>

<blockquote>
<pre><code>    $ helm install our-app
</code></pre>
</blockquote>

<p>and then we can test that image</p>

<blockquote>
<pre><code>    $ helm test release-with-our-app
</code></pre>
</blockquote>

<p>Things I would like to clarify:  </p>

<ol>
<li><p>Should we have two separate docker images or one for application and tests?... </p>

<p>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.</p>

<p>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. </p>

<p>Is my assumption correct and we should have a separate image for these tests?</p></li>
<li><p>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? </p></li>
<li><p>Also in case if we have two separate images. Should I specify the test run in a docker file for tests?
for example :</p></li>
</ol>

<blockquote>
<pre><code>   CMD ["sh", "-c", "gradle test -Denvironment=$ENVIRONMENT"]
</code></pre>
</blockquote>

<p>Or should it be inside chart</p>

<blockquote>
<pre><code>   our-app/templates/tests/test-our-app.yaml
</code></pre>
</blockquote>

<p>For example test.yaml from mysql repo: </p>

<blockquote>
  <p><a href="https://github.com/helm/charts/blob/master/stable/mysql/templates/tests/test-configmap.yaml" rel="noreferrer">https://github.com/helm/charts/blob/master/stable/mysql/templates/tests/test-configmap.yaml</a></p>
</blockquote>

<ol start="4">
<li>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 <a href="https://stackoverflow.com/questions/52636571/how-to-pass-dynamic-arguments-to-a-helm-chart-that-runs-a-job">How to pass dynamic arguments to a helm chart that runs a job</a>  ?</li>
</ol>

<p>an example you can find  in mysql chart by the following link
<a href="https://github.com/helm/charts/tree/master/stable/mysql/templates" rel="noreferrer">https://github.com/helm/charts/tree/master/stable/mysql/templates</a></p>
<p>Answering my own question:</p>
<ol>
<li>We made a separate docker image for helm tests due to the following reasons:<br />
1.1 When helm smoke docker image is separate that makes it free of any constraints of the main app docker image. So you can install any libraries and avoid following some security guidelines that main app has to follow.<br />
1.2 There is no restriction on the size of a docker image for helm test becasue it is short living image , the image of helm test is a live for a duration of tests inside.</li>
<li>We marry them via Chart version. So the image of main application has always the same version as the helm tests docker image.
<a href="https://i.stack.imgur.com/LahUi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LahUi.png" alt="enter image description here" /></a></li>
</ol>
<p>We don't have to pass anything,  when you run &quot;helm test yourapp&quot;, helm looks for successfully deployed version of yourapp and runs helm test with that version.<br />
<a href="https://i.stack.imgur.com/yc2vb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yc2vb.png" alt="enter image description here" /></a><br />
3. When you run the &quot;helm test yourapp&quot; command. Helm looks in file<br />
yourapp/templates/tests/smoke-test.yaml<br />
calls command that is specified by the following path:<br />
spec/containers/command: [&quot;sh&quot;, &quot;-c&quot;, &quot;your command&quot;]
plz have a look on the screenshot or go to git repo of mysql chart <a href="https://github.com/helm/charts/tree/master/stable/mysql/templates" rel="noreferrer">https://github.com/helm/charts/tree/master/stable/mysql/templates</a> <a href="https://i.stack.imgur.com/v6PFn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/v6PFn.png" alt="enter image description here" /></a></p>
<ol start="4">
<li>The best way to pass data and Env specific data is passing them via config maps, env variables, and secrets as Hanx unanswered. If it is stored in such a way then you can populate such data via helm values files and it will be easy to update. We found that having env specific data inside image is a bad solution because if for example a URL/host changes in some environment we need to create a new build instead of just updating a values file and performing deploy.</li>
</ol>
