Integration testing deployed services using “helm test”

谁都会走 提交于 2020-01-06 04:36:07

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/56688514/integration-testing-deployed-services-using-helm-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!