testcontainers / testcontainers/testcontainers-python

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

Đang mở
#1,049 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

🚀 enhancement
Ngôn ngữ chính
Python
Star
2.3k
Fork
386
Merge trung bình
4 giờ 40 phút
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong src/testcontainers/compose/compose.py, đặc biệt là lớp ComposeContainer xung quanh phương thức start() được tham chiếu, và so sánh với các triển khai Java ComposeContainer và ComposeDelegate được liên kết. Truy vết các API đăng ký Python Ryuk hiện có trước khi quyết định cách đăng ký các nhãn của dự án Compose. Công việc được xem là hoàn tất khi các container do ComposeContainer khởi chạy được dọn dẹp an toàn sau sự cố hoặc thao tác dừng cưỡng bức, với phạm vi kiểm thử phù hợp cho hành vi này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
docker, docker-compose, python
Lĩnh vực
devops, testing-qa
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
68/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.