如何使用舵图测试进行集成测试? [英] How to use helm chart test to do integration tests?

查看:73
本文介绍了如何使用舵图测试进行集成测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用它来运行一些集成测试,以便验证我部署的服务代码实际上在做正确的事.

I am trying to use it to run some integration tests, so to verify the service code I am deploying is actually doing the right thing.

我的基本设置方式(如此处所述: https://docs.helm. sh/developing_charts/#chart-tests )创建此templates/tests/integration-test.yaml图表测试文件,并在其中指定运行容器,该容器基本上是一个自定义的maven映像,其中添加了测试代码,并且只需启动测试容器通过命令"mvn test",它将对整个头盔版本部署的kube服务进行一些简单的卷曲检查.

Basically how I setup is (as described here: https://docs.helm.sh/developing_charts/#chart-tests) creating this templates/tests/integration-test.yaml chart test file, and inside it specify to run a container, which basically is a customized maven image with test code added in and the test container is simply started by command "mvn test", which does some simple curl check on the kube service this whole helm release deploys.

通过这种方式,舵测试确实有效.

In this way, the helm test does work.

但是,问题是,在运行头盔测试期间,新版本的服务代码实际上已经在线并且暴露给外界/用户.当然,如果头盔测试失败,我可以立即回滚,但这不会阻止我暂时将服务代码的问题版本托管到外界.

However, the issue is, during the helm test is running, the new version of the service code is actually already online and being exposed to the outside world/users. I can of course immediately do a roll back if the helm test fails, but this will not stop me hosting the problem-version of the service code for a while to the outside world.

有没有一种方法,在Pod启动之后但在向Kubernetes服务公开之前,可以在Pod上运行服务/集成测试?

Is there a way, where one can run a service/integration test on a pod, after the pod is started but before it is exposed to the Kubernetes service?

推荐答案

理想情况下,您首先将在专用的测试集群或名称空间的测试环境中进行安装和测试.要进行其他检查,您可以先将图表安装到新的名称空间中,然后在其中运行测试,然后在所有名称空间通过后删除该名称空间.这确实要求编写测试的方式应使其能够访问特定于该命名空间的URL.无论如何,基于服务名称的群集内部URL都是相对于名称空间的,但是如果您在测试中使用外部URL,则需要将其切换为内部URL或使用前缀.

Ideally you'll install and test on a test environment first, either a dedicated test cluster or namepsace. For an additional check you could install the chart first into a new namespace and let the tests run there and then delete that namespace when it is all passed. This does require writing the tests in a way that they can hit URLs that are specific to that namespace. Cluster-internal URLs based on service names will be namespace-relative anyway but if you use external URLs in the tests then you'd either need to switch them to internal or use prefixing.

这篇关于如何使用舵图测试进行集成测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆