Reputation: 108
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.
newman run "test.postman_collection.json" -e "azure.postman_environment.json" --bail
Upvotes: 0
Views: 4192
Reputation: 393
I posted an example configuration for a Helm chart test that executes a postman collection here:
I achieved the expected behavior with Helm Chart Tests and the postman/newman Docker image.
My Helm template for the test execution:
apiVersion: v1
kind: Pod
metadata:
name: API Test
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: PostmanTest
image: postman/newman:latest
args:
- run
- <url-to-postman-collection>
# In case you need to define the hostname in the collection
# Use {{baseUrl}} in the request URL
- --env-var
- baseUrl=<kubernetes-host-name>
In your pipeline you now have to wait until the pod is ready (this could be checked with an implemented readiness probe) and then the chart test can be executed with
helm test
Upvotes: 1
Reputation: 5531
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:
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.
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.
Upvotes: 3