@@ -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 } ;
@@ -167,7 +168,7 @@ impl TestEnv {
167168 error ! ( err=?error, "failed to start a quickwit server" ) ;
168169 }
169170 } ) ;
170- wait_for_server_ready ( ( [ 127 , 0 , 0 , 1 ] , self . rest_listen_port ) . into ( ) ) . await ?;
171+ wait_for_quickwit_ready ( self . rest_listen_port ) . await ?;
171172 Ok ( ( ) )
172173 }
173174
@@ -179,6 +180,26 @@ impl TestEnv {
179180 }
180181}
181182
183+ async fn wait_for_quickwit_ready ( rest_listen_port : u16 ) -> anyhow:: Result < ( ) > {
184+ let ready_url = format ! ( "http://127.0.0.1:{rest_listen_port}/health/readyz" ) ;
185+ wait_until_predicate (
186+ || async {
187+ let Ok ( response) = reqwest:: get ( & ready_url) . await else {
188+ return false ;
189+ } ;
190+ if !response. status ( ) . is_success ( ) {
191+ return false ;
192+ }
193+ response. json :: < bool > ( ) . await . unwrap_or ( false )
194+ } ,
195+ Duration :: from_secs ( 10 ) ,
196+ Duration :: from_millis ( 50 ) ,
197+ )
198+ . await
199+ . with_context ( || format ! ( "quickwit server did not become ready at `{ready_url}`" ) ) ?;
200+ Ok ( ( ) )
201+ }
202+
182203pub enum TestStorageType {
183204 S3 ,
184205 LocalFileSystem ,
0 commit comments