testcontainers / testcontainers/testcontainers-python

Feature: Ryuk support in ComposeContainer class (like in Java)

オープン
#1,049 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

🚀 enhancement
主要言語
Python
スター
2.3k
フォーク
386
平均マージ
4時間 40分
マージ済み PR(30日)
1

説明

What are you trying to do?

When using testcontainers for Python in a CI/CD environment containers started using the ComposeContainer class are not stopped in crash or force-stop scenarios. The same class in Java cleaned up the started Containers via Ryuk.

It would be nice if the Python class ComposeContainer provides the same functionality of cleaning up the containers it started in a safe manner. (for example with Ryuk)

Safe cleanup of containers seems to be a core feature of the other *Container classes and is missing for compose files using the ComposeContainer class.

Here is a brief summary of how it is implemented in Java and potential changes:
ComposeContainer class in Java:

https://github.com/testcontainers/testcontainers-java/blob/905a445ad8b701e4c531aa652e42179072a88d01/core/src/main/java/org/testcontainers/containers/ComposeContainer.java#L33

In the "start()" method "registerContainersForShutdown" is called. See:

https://github.com/testcontainers/testcontainers-java/blob/905a445ad8b701e4c531aa652e42179072a88d01/core/src/main/java/org/testcontainers/containers/ComposeContainer.java#L160

In "registerContainersForShutdown"

https://github.com/testcontainers/testcontainers-java/blob/905a445ad8b701e4c531aa652e42179072a88d01/core/src/main/java/org/testcontainers/containers/ComposeDelegate.java#L244-L248

the line ".registerLabelsFilterForCleanup(Collections.singletonMap("com.docker.compose.project", project));" effectivly adds a label filter to Ryuk using the official Docker property com.docker.compose.project with a random project ID. (see constructor of ComposeDelegate for "project" property)

Python doesn't have this functionality, see https://github.com/testcontainers/testcontainers-python/blob/a3476488ac1f7526a9c22d65251c8639d7089326/src/testcontainers/compose/compose.py#L84 for the analog of the ComposeContainer class in Python and https://github.com/testcontainers/testcontainers-python/blob/a3476488ac1f7526a9c22d65251c8639d7089326/src/testcontainers/compose/compose.py#L318 for the "start()" method that has no code to interact with Ryuk.

Why should it be done this way?

Please provide the same or similar functionality to allow safe usage of ComposeContainer class like in Java.
Thank you.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

src/testcontainers/compose/compose.py から始め、特に参照されている start() メソッド周辺の ComposeContainer クラスを確認し、リンクされている Java ComposeContainer および ComposeDelegate の実装と比較してください。Compose プロジェクトのラベルをどのように登録すべきかを決める前に、既存の Python Ryuk 登録 API を追跡してください。ComposeContainer によって起動されたコンテナがクラッシュや強制停止の後に安全にクリーンアップされ、この動作に関する適切なカバレッジがあることが完了条件です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
docker, docker-compose, python
領域
devops, testing-qa
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
68/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。