@@ -16,13 +16,14 @@ use std::fs;
1616use std:: path:: { Path , PathBuf } ;
1717use std:: str:: FromStr ;
1818use std:: sync:: Arc ;
19+ use std:: time:: Duration ;
1920
2021use anyhow:: Context ;
2122use predicates:: str;
2223use quickwit_cli:: ClientArgs ;
2324use quickwit_cli:: service:: RunCliCommand ;
2425use quickwit_common:: net:: find_available_tcp_port;
25- use quickwit_common:: test_utils:: wait_for_server_ready ;
26+ use quickwit_common:: test_utils:: wait_until_predicate ;
2627use quickwit_common:: uri:: Uri ;
2728use quickwit_config:: service:: QuickwitService ;
2829use quickwit_metastore:: { IndexMetadata , IndexMetadataResponseExt , MetastoreResolver } ;
@@ -174,7 +175,7 @@ impl TestEnv {
174175 _ = server_handle => { }
175176 }
176177 } ) ;
177- wait_for_server_ready ( ( [ 127 , 0 , 0 , 1 ] , self . rest_listen_port ) . into ( ) ) . await ?;
178+ wait_for_quickwit_ready ( self . rest_listen_port ) . await ?;
178179 Ok ( ( ) )
179180 }
180181
@@ -186,6 +187,26 @@ impl TestEnv {
186187 }
187188}
188189
190+ async fn wait_for_quickwit_ready ( rest_listen_port : u16 ) -> anyhow:: Result < ( ) > {
191+ let ready_url = format ! ( "http://127.0.0.1:{rest_listen_port}/health/readyz" ) ;
192+ wait_until_predicate (
193+ || async {
194+ let Ok ( response) = reqwest:: get ( & ready_url) . await else {
195+ return false ;
196+ } ;
197+ if !response. status ( ) . is_success ( ) {
198+ return false ;
199+ }
200+ response. json :: < bool > ( ) . await . unwrap_or ( false )
201+ } ,
202+ Duration :: from_secs ( 10 ) ,
203+ Duration :: from_millis ( 50 ) ,
204+ )
205+ . await
206+ . with_context ( || format ! ( "quickwit server did not become ready at `{ready_url}`" ) ) ?;
207+ Ok ( ( ) )
208+ }
209+
189210pub enum TestStorageType {
190211 S3 ,
191212 LocalFileSystem ,
0 commit comments