Search code examples
javakubernetespostmankubernetes-helmnewman

Integration testing deployed services using "helm test"


I'm using helm charts to deploy several REST services to Microsoft Azure. Some of these services communicate with each other and to some databases. After the deployment I want to test if "everything" works as expected. To be more precise, I want to send some HTTP requests to one of the services and check if the response makes sense. In automated tests of course.

I saw that it's possible to run basic commands after the deployment using "helm test", but this is not exactly what I need.

In some earlier approach I used Newman to execute a Postman collection in a script after the deployment. The Postman collection defined several requests and the corresponding tests.

Now I don't know how to do it in the new environment (Azure) and deployment pipeline (helm, k8s).

It would be nice to have something like this again. But for me it's not clear how to do it, e.g.

  • how can I use Newman in the "helm test" scope?
  • how can I ensure, that the deployed Pods are all "Running" before starting the test (some wait time? status check?)?

newman run "test.postman_collection.json" -e "azure.postman_environment.json" --bail


Solution

  • Helm test is very flexible, because it runs any Kubernetes YAML including any Docker image. As an example, you can check tests for the MySQL Helm Chart.

    So, coming to your questions:

    1. To use Newman, you just need to find a Docker image with the Newman installed (e.g. the official one postman/newman or build your own). To use your JSON configuration files, you can either put them as ConfigMap or copy them into the container. Check he MySQL Helm Chart for more details.

    2. You're right that you need to wait until your system is ready before running the tests. AFAIK this is not covered by Helm Test. So you need to either put sleep into your script or actively check with kubectl until the PODs are ready.