testcontainers / testcontainers/testcontainers-python
Bug: HealthcheckWaitStrategy returns error with DockerCompose
オープン
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 2.3k
- フォーク
- 386
- 平均マージ
- 4時間 40分
- マージ済み PR(30日)
- 1
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
testcontainers/compose/compose.py の start 付近と、testcontainers/core/wait_strategies.py の HealthcheckWaitStrategy.wait_until_ready 付近を読みます。提示された Docker Compose の例を再現し、既存の wait-strategy テストを確認します。DockerCompose の healthcheck 待機がサポートされていない ComposeContainer 属性にアクセスしなくなり、リグレッションテストがパスすれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- docker-compose, python
- 領域
- devops, testing-qa
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100