@@ -2812,21 +2812,34 @@ mod tests {
28122812
28132813 println ! ( "All partitions: {:#?}" , partitions) ;
28142814
2815- let plans = service
2816- . plan_query ( "SELECT sum(num) from foo.numbers where num = 50" )
2817- . await
2818- . unwrap ( ) ;
2815+ // Semi-busy-wait for, or, seemingly, induce, compaction for 2000 ms.
2816+ let num_attempts = 100 ;
2817+ for i in 0 ..num_attempts {
2818+ tokio:: time:: sleep ( Duration :: from_millis ( 20 ) ) . await ;
2819+
2820+ let plans = service
2821+ . plan_query ( "SELECT sum(num) from foo.numbers where num = 50" )
2822+ . await
2823+ . unwrap ( ) ;
2824+
2825+ let worker_plan = pp_phys_plan ( plans. worker . as_ref ( ) ) ;
2826+ let parquet_regex = Regex :: new ( r"\d+-[a-z0-9]+\.parquet" ) . unwrap ( ) ;
2827+ let matches = parquet_regex. captures_iter ( & worker_plan) . count ( ) ;
2828+ let chunk_parquet_regex = Regex :: new ( r"\d+-[a-z0-9]+\.chunk\.parquet" ) . unwrap ( ) ;
2829+ let chunk_matches = chunk_parquet_regex. captures_iter ( & worker_plan) . count ( ) ;
28192830
2820- let worker_plan = pp_phys_plan ( plans. worker . as_ref ( ) ) ;
2821- println ! ( "Worker Plan: {}" , worker_plan) ;
2822- let parquet_regex = Regex :: new ( r"\d+-[a-z0-9]+.parquet" ) . unwrap ( ) ;
2823- let matches = parquet_regex. captures_iter ( & worker_plan) . count ( ) ;
2824- assert ! (
28252831 // TODO 2 because partition pruning doesn't respect half open intervals yet
2826- matches < 3 && matches > 0 ,
2827- "{}\n should have 2 and less partition scan nodes" ,
2828- worker_plan
2829- ) ;
2832+ if matches < 3 && matches > 0 && chunk_matches == 0 {
2833+ break ;
2834+ } else if i == num_attempts - 1 {
2835+ panic ! (
2836+ "{}\n should have 2 and less partition scan nodes, matches = {}, chunk_matches = {}" ,
2837+ worker_plan,
2838+ matches,
2839+ chunk_matches,
2840+ ) ;
2841+ }
2842+ }
28302843 } )
28312844 . await ;
28322845 }
0 commit comments