How to use helm chart test to do integration tests?

1/11/2019

I am trying to use it to run some integration tests, so to verify the service code I am deploying is actually doing the right thing.

Basically how I setup is (as described here: https://docs.helm.sh/developing_charts/#chart-tests) creating this templates/tests/integration-test.yaml chart test file, and inside it specify to run a container, which basically is a customized maven image with test code added in and the test container is simply started by command “mvn test”, which does some simple curl check on the kube service this whole helm release deploys.

In this way, the helm test does work.

However, the issue is, during the helm test is running, the new version of the service code is actually already online and being exposed to the outside world/users. I can of course immediately do a roll back if the helm test fails, but this will not stop me hosting the problem-version of the service code for a while to the outside world.

Is there a way, where one can run a service/integration test on a pod, after the pod is started but before it is exposed to the Kubernetes service?

-- Fuyang Liu
kubernetes
kubernetes-helm

2 Answers

2/19/2020

Use the readiness and liveness probes in the pod spec to ensure that the deployment won't even roll out if there are probe failures.

-- Ben Mathews
Source: StackOverflow

1/11/2019

Ideally you'll install and test on a test environment first, either a dedicated test cluster or namepsace. For an additional check you could install the chart first into a new namespace and let the tests run there and then delete that namespace when it is all passed. This does require writing the tests in a way that they can hit URLs that are specific to that namespace. Cluster-internal URLs based on service names will be namespace-relative anyway but if you use external URLs in the tests then you'd either need to switch them to internal or use prefixing.

-- Ryan Dawson
Source: StackOverflow