Skip to content

Commit b6c41f2

Browse files
committed
feat(clickhouse): add HttpWaitStrategy and migrate ClickHouseContainer from deprecated decorator
1 parent 15e99ee commit b6c41f2

File tree

1 file changed

+3
-8
lines changed
  • modules/clickhouse/testcontainers/clickhouse

1 file changed

+3
-8
lines changed

modules/clickhouse/testcontainers/clickhouse/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
# under the License.
1313
import os
1414
from typing import Optional
15-
from urllib.error import HTTPError, URLError
16-
from urllib.request import urlopen
1715

1816
from testcontainers.core.generic import DbContainer
1917
from testcontainers.core.utils import raise_for_deprecated_parameter
20-
from testcontainers.core.waiting_utils import wait_container_is_ready
18+
from testcontainers.core.wait_strategies import HttpWaitStrategy
2119

2220

2321
class ClickHouseContainer(DbContainer):
@@ -58,12 +56,9 @@ def __init__(
5856
self.with_exposed_ports(self.port)
5957
self.with_exposed_ports(8123)
6058

61-
@wait_container_is_ready(HTTPError, URLError)
6259
def _connect(self) -> None:
63-
# noinspection HttpUrlsUsage
64-
url = f"http://{self.get_container_host_ip()}:{self.get_exposed_port(8123)}"
65-
with urlopen(url) as r:
66-
assert b"Ok" in r.read()
60+
strategy = HttpWaitStrategy(8123).for_response_predicate(lambda response: "Ok" in response)
61+
strategy.wait_until_ready(self)
6762

6863
def _configure(self) -> None:
6964
self.with_env("CLICKHOUSE_USER", self.username)

0 commit comments

Comments
 (0)