1515from dataclasses import dataclass
1616import threading
1717import typing
18- from urllib .error import URLError
1918import socket
2019from contextlib import contextmanager , asynccontextmanager
2120
2524from restate .server_types import RestateAppT
2625from restate .types import TestHarnessEnvironment
2726from 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
3029import 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