@@ -123,15 +123,30 @@ void shouldIgnoreCheckpointStrideOutsideNormalState() throws Exception {
123123 QueryCircuitBreaker breaker = fixture .breaker (configuration (true , 100 , 200 , 300 , 400 , 300 , 200 , 25 , 10 , 0 ,
124124 7 ), 0 );
125125
126- assertFalse (readIgnoreCheckpointStride ());
126+ retryAssertion (() -> assertFalse (readIgnoreCheckpointStride () ));
127127
128128 fixture .freeMemoryMb .set (350 );
129129 assertEquals ("WARN" , breaker .snapshotStatus ().getState ());
130- assertTrue (readIgnoreCheckpointStride ());
130+ retryAssertion (() -> assertTrue (readIgnoreCheckpointStride () ));
131131
132132 fixture .freeMemoryMb .set (1024 );
133133 assertEquals ("NORMAL" , breaker .snapshotStatus ().getState ());
134- assertFalse (readIgnoreCheckpointStride ());
134+ retryAssertion (() -> assertFalse (readIgnoreCheckpointStride ()));
135+ }
136+
137+ private static void retryAssertion (Runnable assertion ) throws InterruptedException {
138+ final int retries = 100 ;
139+ for (int i = 0 ; i < retries ; i ++) {
140+ try {
141+ assertion .run ();
142+ break ;
143+ } catch (AssertionError e ) {
144+ if (i == retries - 1 ) {
145+ throw e ;
146+ }
147+ Thread .sleep (100 );
148+ }
149+ }
135150 }
136151
137152 @ Test
@@ -374,10 +389,19 @@ private static boolean readHeavyOperatorExecutionEnabled() throws Exception {
374389 return field .getBoolean (null );
375390 }
376391
377- private static boolean readIgnoreCheckpointStride () throws Exception {
378- Field field = QueryExecutionContext .class .getDeclaredField ("ignoreCheckpointStride" );
392+ private static boolean readIgnoreCheckpointStride () {
393+ Field field = null ;
394+ try {
395+ field = QueryExecutionContext .class .getDeclaredField ("ignoreCheckpointStride" );
396+ } catch (NoSuchFieldException e ) {
397+ throw new RuntimeException (e );
398+ }
379399 field .setAccessible (true );
380- return field .getBoolean (null );
400+ try {
401+ return field .getBoolean (null );
402+ } catch (IllegalAccessException e ) {
403+ throw new RuntimeException (e );
404+ }
381405 }
382406
383407 private static Set <Long > threadIds (String threadName ) {
0 commit comments