testcontainers / testcontainers/testcontainers-python
Bug: HealthcheckWaitStrategy returns error with DockerCompose
Chưa có ai nhận issue này.
- 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ả
Describe the bug
When applying a 'waiting_for' to a DockerCompose object with a HealthcheckWaitStrategy, it returns an AttributeError: “ComposeContainer” object has no attribute “attrs”.
To Reproduce
import os
from testcontainers.compose import DockerCompose
from testcontainers.core.wait_strategies import HealthcheckWaitStrategy
BASE_DIR = os.path.dirname(__file__)
compose = DockerCompose(context=BASE_DIR, compose_file_name = "docker-compose.yml")
compose.waiting_for({"web": HealthcheckWaitStrategy().with_startup_timeout(60)})
compose.start()
docker-compose.yml:
version: '3.8'
services:
web:
image: nginx
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
Traceback:
Traceback (most recent call last):
File "<path>/test.py", line 9, in <module>
compose.start()
File "testcontainers/compose/compose.py", line 303, in start
strategy.wait_until_ready(container)
File "testcontainers/core/wait_strategies.py", line 487, in wait_until_ready
health = wrapped.attrs.get("State", {}).get("Health", {})
^^^^^^^^^^^^^
AttributeError: 'ComposeContainer' object has no attribute 'attrs'
Runtime environment
$ uname -a
Linux kali 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 3.12.1
$ poetry show | grep testcontainers
testcontainers 4.13.2
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Đọc testcontainers/compose/compose.py quanh start và testcontainers/core/wait_strategies.py quanh HealthcheckWaitStrategy.wait_until_ready. Tái hiện ví dụ Docker Compose được cung cấp và kiểm tra các test của wait-strategy hiện có. Hoàn tất khi việc chờ healthcheck của DockerCompose không còn truy cập vào một thuộc tính ComposeContainer không được hỗ trợ và regression test chạy thành công.
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-compose, python
- Lĩnh vực
- devops, testing-qa
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 35/100