|
1 | | -from typing import TYPE_CHECKING |
2 | | - |
3 | | -from requests import ConnectionError, get |
4 | | - |
5 | 1 | from minio import Minio |
6 | 2 | from testcontainers.core.container import DockerContainer |
7 | 3 | 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 |
12 | 5 |
|
13 | 6 |
|
14 | 7 | class MinioContainer(DockerContainer): |
@@ -56,7 +49,11 @@ def __init__( |
56 | 49 | secret_key: Secret key for client connections. |
57 | 50 | """ |
58 | 51 | 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 | + ) |
60 | 57 | self.port = port |
61 | 58 | self.access_key = access_key |
62 | 59 | self.secret_key = secret_key |
@@ -97,18 +94,3 @@ def get_config(self) -> dict: |
97 | 94 | "access_key": self.access_key, |
98 | 95 | "secret_key": self.secret_key, |
99 | 96 | } |
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