常见问题

Testcontainers Cloud 与开源 Testcontainers 框架有何不同?

开源 Testcontainers 是一个库,提供轻量级 API,用于使用包装在 Docker 容器中的真实服务引导本地开发和测试依赖项,而 Testcontainers Cloud 为这些容器提供云运行时。这减少了本地环境的资源压力,并提供了更高的可扩展性,尤其是在 CI/CD 工作流程中,可以在整个组织中实现一致的 Testcontainers 体验。

我可以用 Testcontainers Cloud 运行哪些类型的容器?

Testcontainers Cloud 支持您通常在 Testcontainers 框架中使用的任何容器,包括数据库(PostgreSQL、MySQL、MongoDB)、消息代理(Kafka、RabbitMQ)以及集成测试所需的其它服务。

我是否需要更改现有的测试代码才能使用 Testcontainers Cloud?

不需要,您无需更改现有的测试代码。Testcontainers Cloud 与开源 Testcontainers 框架无缝集成。设置云配置后,它会自动管理云中的容器,无需更改代码。

如何将 Testcontainers Cloud 集成到我的项目中?

要集成 Testcontainers Cloud,您需要安装 Testcontainers Desktop 应用程序,并在菜单中选择“使用 Testcontainers Cloud 运行”选项。在 CI 中,您需要添加一个工作流程步骤,该步骤下载 Testcontainers Cloud 代理。除了在本地通过 Testcontainers Desktop 应用程序启用云运行时或在 CI 中安装 Testcontainers Cloud 代理外,无需进行代码更改。

我可以在 CI/CD 管道中使用 Testcontainers Cloud 吗?

是的,Testcontainers Cloud 旨在在 CI/CD 管道中高效工作。它通过将您使用 Testcontainers 库启动的容器卸载到云中来帮助减少构建时间和资源瓶颈,使其成为持续测试环境的理想选择。

使用 Testcontainers Cloud 的好处是什么?

主要好处包括减少本地机器和 CI 服务器上的资源使用、可扩展性(无需性能下降即可运行更多容器)、一致的测试环境、集中监控以及简化的 CI 配置,消除了运行 Docker-in-Docker 或特权守护程序的安全隐患。

Testcontainers Cloud 是否支持所有编程语言?

Testcontainers Cloud 支持与开源 Testcontainers 库一起使用的任何语言,包括 Java、Python、Node.js、Go 等。只要您的项目使用 Testcontainers,就可以将其卸载到 Testcontainers Cloud。

Testcontainers Cloud 如何处理容器清理?

虽然 Testcontainers 库自动处理容器生命周期管理,但 Testcontainers Cloud 管理分配的云工作程序生命周期。这意味着容器由 Testcontainers 库在测试完成后启动、监控和清理,并且这些容器运行所在的 worker 将在 Testcontainers Cloud 大约 35 分钟的空闲期后自动删除。这种方法使开发人员无需手动管理容器和关联的云资源。

Testcontainers Cloud 是否有免费层或定价模式?

Testcontainers Cloud 的定价详情可在定价页面上找到。