Skip to content

Commit c00fcd7

Browse files
Remove usage of deprecated testcontainers wait api.
1 parent 406946c commit c00fcd7

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

python/restate/harness.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from dataclasses import dataclass
1616
import threading
1717
import typing
18-
from urllib.error import URLError
1918
import socket
2019
from contextlib import contextmanager, asynccontextmanager
2120

@@ -25,7 +24,7 @@
2524
from restate.server_types import RestateAppT
2625
from restate.types import TestHarnessEnvironment
2726
from testcontainers.core.container import DockerContainer # type: ignore
28-
from testcontainers.core.waiting_utils import wait_container_is_ready # type: ignore
27+
from testcontainers.core.wait_strategies import CompositeWaitStrategy, HttpWaitStrategy
2928

3029
import httpx
3130

@@ -153,6 +152,12 @@ def __init__(self, image, always_replay, disable_retries):
153152
self.with_env("RESTATE_WORKER__INVOKER__RETRY_POLICY__TYPE", "none")
154153

155154
self.with_kwargs(extra_hosts={"host.docker.internal": "host-gateway"})
155+
self.waiting_for(
156+
CompositeWaitStrategy(
157+
HttpWaitStrategy(8080, "/restate/health").for_status_code(200),
158+
HttpWaitStrategy(9070, "/health").for_status_code(200),
159+
)
160+
)
156161

157162
def ingress_url(self):
158163
"""return the URL to access the Restate ingress"""
@@ -170,12 +175,6 @@ def get_ingress_client(self):
170175
"""return an httpx client to access the ingress interface"""
171176
return httpx.Client(base_url=self.ingress_url())
172177

173-
@wait_container_is_ready(httpx.HTTPError, URLError)
174-
def _wait_healthy(self):
175-
"""wait for restate's health checks to pass"""
176-
self.get_ingress_client().get("/restate/health").raise_for_status()
177-
self.get_admin_client().get("/health").raise_for_status()
178-
179178
def start(self, stream_logs=False):
180179
"""start the container and wait for health checks to pass"""
181180
super().start()
@@ -189,7 +188,6 @@ def stream_log():
189188
thread.start()
190189
self.log_thread = thread
191190

192-
self._wait_healthy()
193191
return self
194192

195193

0 commit comments

Comments
 (0)