问题
I am using Helm kubernetes deployment and I want to run the postman test cases before a final deployment, and if any test case fails then rollback (or retain the current deployment like Blue-Green deployment). How to achieve this?
回答1:
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>
After install the helm chart the tests can be executed with
helm test
来源:https://stackoverflow.com/questions/56917951/how-to-run-postman-test-cases-by-helm-and-rollback-to-last-successful-version-if