Skip to content

Commit 3903509

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

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

modules/minio/testcontainers/minio/__init__.py

Lines changed: 6 additions & 24 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):
@@ -56,7 +49,11 @@ def __init__(
5649
secret_key: Secret key for client connections.
5750
"""
5851
raise_for_deprecated_parameter(kwargs, "port_to_expose", "port")
59-
super().__init__(image, **kwargs)
52+
super().__init__(
53+
image,
54+
_wait_strategy=HttpWaitStrategy(port, "/minio/health/live"),
55+
**kwargs,
56+
)
6057
self.port = port
6158
self.access_key = access_key
6259
self.secret_key = secret_key
@@ -97,18 +94,3 @@ def get_config(self) -> dict:
9794
"access_key": self.access_key,
9895
"secret_key": self.secret_key,
9996
}
100-
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-
109-
def start(self) -> "MinioContainer":
110-
"""This method starts the Minio container and runs the healthcheck
111-
to verify that the container is ready to use."""
112-
super().start()
113-
self._healthcheck()
114-
return self

0 commit comments

Comments
 (0)