常見挑戰與問題

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 桌面應用程式並在選單中選擇“使用 Testcontainers Cloud 執行”選項。在 CI 中,您需要新增一個工作流步驟來下載 Testcontainers Cloud 代理。除了透過 Testcontainers 桌面應用程式在本地啟用雲執行時或在 CI 中安裝 Testcontainers Cloud 代理之外,無需更改程式碼。

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

是的,Testcontainers Cloud 旨在 CI/CD 管道中高效工作。它透過將您使用 Testcontainers 庫啟動的容器解除安裝到雲中,從而幫助減少構建時間和資源瓶頸,使其非常適合持續測試環境。

使用 Testcontainers Cloud 有什麼好處?

主要優勢包括減少本地機器和 CI 伺服器上的資源使用,可擴充套件性(在不降低效能的情況下執行更多容器),一致的測試環境,集中監控,以及透過消除 Docker-in-Docker 或特權守護程序帶來的安全問題,簡化 CI 配置。

Testcontainers Cloud 支援所有程式語言嗎?

Testcontainers Cloud 支援與開源 Testcontainers 庫一起使用的任何語言,包括 Java、Python、Node.js、Go 等。只要您的專案使用 Testcontainers,就可以將其解除安裝到 Testcontainers Cloud。

Testcontainers Cloud 如何處理容器清理?

雖然 Testcontainers 庫會自動處理容器生命週期管理,但 Testcontainers Cloud 管理分配的雲工作器生命週期。這意味著容器在測試完成後由 Testcontainers 庫啟動、監控和清理,並且執行這些容器的工作器將在大約 35 分鐘的空閒期後由 Testcontainers Cloud 自動移除。這種方法使開發人員無需手動管理容器和相關的雲資源。

Testcontainers Cloud 有免費套餐或定價模型嗎?

Testcontainers Cloud 的定價詳情可在定價頁面找到。