<p>I have set up Kubernetes environment locally using minikube. I create a Job which has 3 containers. </p>

<ul>
<li>Hub</li>
<li>Chrome</li>
<li>App ( Selenium-TestNG) </li>
</ul>

<p>When I apply/create job, which will set up Hub/Chrome/App. Execute selenium tests. </p>

<p>If all the tests are completed successfully, you will see the status of Container like below</p>

<p><a href="https://i.stack.imgur.com/CXsJt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CXsJt.png" alt="Container List after completion"></a></p>

<p>The result from webAutomation1 app
<a href="https://i.stack.imgur.com/si6Qe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/si6Qe.png" alt="log"></a></p>

<p>The above things are as expected. Looks good in terms of container listing</p>

<p>Now, if we have completed the app(Execution of tests) with some failures like below</p>

<p><a href="https://i.stack.imgur.com/MqpXQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MqpXQ.png" alt="fail log"></a></p>

<p>Then, my container listing will show it as error
<a href="https://i.stack.imgur.com/rCGCb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rCGCb.png" alt="error container"></a></p>

<p>I use ITestListenr to write logs to console as of now. What is that making container STATE to turn Error.? Is there anything I don't see in terms of integration between container and app?</p>

<p>It would be greatly appreciated if someone helps me with this.</p>

Manoj Kengudelu
<p>As per <a href="https://testng.org/doc/documentation-main.html#testng-exit-codes" rel="nofollow noreferrer">TestNG exit codes</a>:</p>

<blockquote>
  <p>When TestNG completes execution, it exits with a return code. This
  return code can be inspected to get an idea on the nature of failures
  (if there were any). The following table summarises the different exit
  codes that TestNG currently uses.</p>

<pre><code>/**
 * |---------------------|---------|--------|-------------|------------------------------------------|
 * | FailedWithinSuccess | Skipped | Failed | Status Code | Remarks                                  |
 * |---------------------|---------|--------|-------------|------------------------------------------|
 * | 0                   | 0       | 0      | 0           | Passed tests                             |
 * | 0                   | 0       | 1      | 1           | Failed tests                             |
 * | 0                   | 1       | 0      | 2           | Skipped tests                            |
 * | 0                   | 1       | 1      | 3           | Skipped/Failed tests                     |
 * | 1                   | 0       | 0      | 4           | FailedWithinSuccess tests                |
 * | 1                   | 0       | 1      | 5           | FailedWithinSuccess/Failed tests         |
 * | 1                   | 1       | 0      | 6           | FailedWithinSuccess/Skipped tests        |
 * | 1                   | 1       | 1      | 7           | FailedWithinSuccess/Skipped/Failed tests |
 * |---------------------|---------|--------|-------------|------------------------------------------|
 */
</code></pre>
</blockquote>

<p>Your container is probably using the TestNG as the main process, and any test that is not considered <code>Passed tests</code> (i.e., exit code different than 0) will result in a pod with the terminated/error state.</p>

<p>You can confirm this by <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/determine-reason-pod-failure/" rel="nofollow noreferrer">Determining the Reason for Pod Failure</a>.</p>

<p>e.g: You can check your pod state; the output will be something like this:</p>

<pre><code>$ kubectl get my-pod-name -o=json | jq .status.containerStatuses[].state
{
  "terminated": {
    "containerID": "docker://9bc2497ec0d2bc3b1b62483c217aaaaa1027102a5f7ff1688f47b94254",
    "exitCode": 1,
    "finishedAt": "2019-10-28T02:00:10Z",
    "reason": "Error",
    "startedAt": "2019-10-28T02:00:05Z"
  }
}
</code></pre>

<p>and check if the exit code matches your TestNG status code.</p>
