Skip to content

Commit 79bff0f

Browse files
committed
fix(minio): Use wait strategy instead of deprecated decorator
Part of fixing #874.
1 parent 5c1504c commit 79bff0f

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

modules/minio/testcontainers/minio/__init__.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
from typing import TYPE_CHECKING
2-
3-
from requests import ConnectionError, get
4-
51
from minio import Minio
62
from testcontainers.core.container import DockerContainer
73
from testcontainers.core.utils import raise_for_deprecated_parameter
8-
from testcontainers.core.waiting_utils import wait_container_is_ready
9-
10-
if TYPE_CHECKING:
11-
from requests import Response
4+
from testcontainers.core.wait_strategies import HttpWaitStrategy
125

136

147
class MinioContainer(DockerContainer):
@@ -98,17 +91,12 @@ def get_config(self) -> dict:
9891
"secret_key": self.secret_key,
9992
}
10093

101-
@wait_container_is_ready(ConnectionError)
102-
def _healthcheck(self) -> None:
103-
"""This is an internal method used to check if the Minio container
104-
is healthy and ready to receive requests."""
105-
url = f"http://{self.get_config()['endpoint']}/minio/health/live"
106-
response: Response = get(url)
107-
response.raise_for_status()
108-
10994
def start(self) -> "MinioContainer":
11095
"""This method starts the Minio container and runs the healthcheck
11196
to verify that the container is ready to use."""
11297
super().start()
113-
self._healthcheck()
98+
HttpWaitStrategy(
99+
port=self.port,
100+
path="/minio/health/live",
101+
).wait_until_ready(self)
114102
return self

0 commit comments

Comments
 (0)