argocd部署后如何运行应用E2E测试?
How to run application E2E test after argocd deployment?
我想知道在使用 ArgoCD 成功部署任何微服务后,我们如何运行 应用程序 E2E(UI 或 API)进行测试。
当前设置:我有 CI 管道设置和 github 操作。在完成任何微服务的 CI 构建后,它会更新位于 github 存储库之一的 helm 值中的 docker 映像版本。 ArgoCD 会轮询此 repo 是否有任何更改,如果存在更改,则会部署在 Kubernetes 集群中。
Intent:我想 运行 应用程序 E2E(UI & API)测试一次 argocd 同步任何微服务部署Helm 图表中定义的对象。但我不确定 github 行动的触发点应该是什么。 E2E 测试 github actions 工作流将如何知道 argocd 已毫无问题地部署微服务并且服务已准备好供自动化测试使用。
ArgoCD 提供了一个称为资源挂钩的功能。挂钩是在同步操作之前、期间和之后 运行 脚本的方法。来自 the official documentation:
的钩子用例
Using a PostSync
hook to run integration and health checks after a deployment.
Hooks can be any type of Kubernetes resource kind, but tend to be Pod, Job, or Argo Workflows.
根据 the GitHub actions documentation,您可以将 POST
请求发送到 Github API PostSync
挂钩模板中的 运行 工作流运行.
这里是问题陈述的完整解决方案。
apiVersion: batch/v1
kind: Job
metadata:
name: api-test-trigger
annotations:
argocd.argoproj.io/hook: PostSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
template:
metadata:
labels:
name: api-test
spec:
containers:
- name: api-test
args:
- /bin/sh
- -ec
- "curl -X POST -H \"Accept: application/vnd.github.v3+json\" -H \"Authorization: token ${GITHUB_TOKEN}\" ${GITHUB_URL} -d '{\"ref\":\"main\"}'"
env:
- name: GITHUB_URL
value: "https://api.github.com/repos/<your org>/<your repo>/actions/workflows/<workflow id>/dispatches"
- name: GITHUB_TOKEN
value: <your PAT>
image: curlimages/curl
您可以从 github 设置创建 PAT 并将 PAT 作为秘密提供。
我想知道在使用 ArgoCD 成功部署任何微服务后,我们如何运行 应用程序 E2E(UI 或 API)进行测试。
当前设置:我有 CI 管道设置和 github 操作。在完成任何微服务的 CI 构建后,它会更新位于 github 存储库之一的 helm 值中的 docker 映像版本。 ArgoCD 会轮询此 repo 是否有任何更改,如果存在更改,则会部署在 Kubernetes 集群中。
Intent:我想 运行 应用程序 E2E(UI & API)测试一次 argocd 同步任何微服务部署Helm 图表中定义的对象。但我不确定 github 行动的触发点应该是什么。 E2E 测试 github actions 工作流将如何知道 argocd 已毫无问题地部署微服务并且服务已准备好供自动化测试使用。
ArgoCD 提供了一个称为资源挂钩的功能。挂钩是在同步操作之前、期间和之后 运行 脚本的方法。来自 the official documentation:
的钩子用例Using a
PostSync
hook to run integration and health checks after a deployment.
Hooks can be any type of Kubernetes resource kind, but tend to be Pod, Job, or Argo Workflows.
根据 the GitHub actions documentation,您可以将 POST
请求发送到 Github API PostSync
挂钩模板中的 运行 工作流运行.
这里是问题陈述的完整解决方案。
apiVersion: batch/v1
kind: Job
metadata:
name: api-test-trigger
annotations:
argocd.argoproj.io/hook: PostSync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
template:
metadata:
labels:
name: api-test
spec:
containers:
- name: api-test
args:
- /bin/sh
- -ec
- "curl -X POST -H \"Accept: application/vnd.github.v3+json\" -H \"Authorization: token ${GITHUB_TOKEN}\" ${GITHUB_URL} -d '{\"ref\":\"main\"}'"
env:
- name: GITHUB_URL
value: "https://api.github.com/repos/<your org>/<your repo>/actions/workflows/<workflow id>/dispatches"
- name: GITHUB_TOKEN
value: <your PAT>
image: curlimages/curl
您可以从 github 设置创建 PAT 并将 PAT 作为秘密提供。