How to run Postman test cases by helm and rollback to last successful version if any test fail

风流意气都作罢 提交于 2021-01-29 11:17:11

问题


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

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