Container STATE is Error when the Test Result has Failure

10/30/2019

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

  • Hub
  • Chrome
  • App ( Selenium-TestNG)

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

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

Container List after completion

The result from webAutomation1 app log

The above things are as expected. Looks good in terms of container listing

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

fail log

Then, my container listing will show it as error error container

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?

It would be greatly appreciated if someone helps me with this.

-- Manoj Kengudelu
containers
kubernetes
minikube
selenium-webdriver
testng

1 Answer

10/30/2019

As per TestNG exit codes:

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.

/**
 * |---------------------|---------|--------|-------------|------------------------------------------|
 * | 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 |
 * |---------------------|---------|--------|-------------|------------------------------------------|
 */

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

You can confirm this by Determining the Reason for Pod Failure.

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

$ 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"
  }
}

and check if the exit code matches your TestNG status code.

-- Eduardo Baitello
Source: StackOverflow