简体   繁体   English

Cloud Build 步骤中的 Cloud Run 集成测试?

[英]Cloud Run integration tests within Cloud Build steps?

I am looking at what Cloud Run suggests for local testing here , which is to docker run your container, and then run your tests against it on localhost:8080.我正在查看 Cloud Run 建议在此处进行本地测试的内容,即docker run您的容器,然后在 localhost:8080 上针对它运行您的测试。 Something like this:像这样的东西:

PORT=8080 && \
docker run -d -p 8080:${PORT} -e PORT=${PORT} gcr.io/myproject/myimage && \
./runtests.sh

Now let's say I want to run these tests as part of a Cloud Build.现在假设我想将这些测试作为 Cloud Build 的一部分运行。 Is it possible/advisable to run docker run as a Cloud Build step?是否可以/建议将docker run作为 Cloud Build 步骤docker run I don't see any gcr.io image for docker itself, so I'm guessing not?我没有看到 docker 本身的任何 gcr.io 图像,所以我猜不是?

Or does it need to be actually deployed to Cloud Run first, then tested?还是需要先实际部署到 Cloud Run,然后再进行测试?

According to the documentation, you should be able to do so.根据文档,您应该能够这样做。 You can create custom steps and there is one image for docker: gcr.io/cloud-builders/docker .您可以创建自定义步骤,并且gcr.io/cloud-builders/docker有一个图像: gcr.io/cloud-builders/docker There's more information about creating custom steps in the cloudbuild.yaml in the public documentation .公共文档中有更多关于在cloudbuild.yaml中创建自定义步骤的信息。

Something similar to this should work for you:类似的东西应该适合你:

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: [ 'run', '-d', '-p', '8080:8080', '-e', 'PORT=8080', 'gcr.io/myproject/myimage' , './runtests.sh']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM