首页 > 解决方案 > 如果任何测试失败,如何通过 helm 运行 Postman 测试用例并回滚到上一个成功的版本

问题描述

我正在使用 Helm kubernetes 部署,我想在最终部署之前运行邮递员测试用例,如果任何测试用例失败,则回滚(或保留当前部署,如蓝绿部署)。如何做到这一点?

标签: kubernetesgoogle-kubernetes-enginekubernetes-helmkubernetes-ingressazure-aks

解决方案


我使用Helm Chart Testspostman/newman Docker image实现了预期的行为。

我用于测试执行的 Helm 模板:

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>

安装 helm chart 后,可以使用以下命令执行测试

掌舵测试


推荐阅读