@@ -549,18 +549,14 @@ public void testMultipleJobTriggering() throws Exception {
549
549
AtomicReference <IndexerState > state = new AtomicReference <>(IndexerState .STOPPED );
550
550
final ThreadPool threadPool = new TestThreadPool (getTestName ());
551
551
try {
552
- final AtomicBoolean isAborted = new AtomicBoolean (false );
553
- DelayedEmptyRollupIndexer indexer = new DelayedEmptyRollupIndexer (threadPool , job , state , null ) {
554
- @ Override
555
- protected void onAbort () {
556
- isAborted .set (true );
557
- }
558
- };
552
+ DelayedEmptyRollupIndexer indexer = new DelayedEmptyRollupIndexer (threadPool , job , state , null );
559
553
indexer .start ();
560
554
for (int i = 0 ; i < 5 ; i ++) {
561
555
final CountDownLatch latch = indexer .newLatch ();
562
556
assertThat (indexer .getState (), equalTo (IndexerState .STARTED ));
563
- assertTrue (indexer .maybeTriggerAsyncJob (System .currentTimeMillis ()));
557
+ // This may take more than one attempt due to a cleanup/transition phase
558
+ // that happens after state change to STARTED (`isJobFinishing`).
559
+ assertBusy (() -> indexer .maybeTriggerAsyncJob (System .currentTimeMillis ()));
564
560
assertThat (indexer .getState (), equalTo (IndexerState .INDEXING ));
565
561
assertFalse (indexer .maybeTriggerAsyncJob (System .currentTimeMillis ()));
566
562
assertThat (indexer .getState (), equalTo (IndexerState .INDEXING ));
@@ -570,7 +566,7 @@ protected void onAbort() {
570
566
assertThat (indexer .getStats ().getNumPages (), equalTo ((long ) i + 1 ));
571
567
}
572
568
final CountDownLatch latch = indexer .newLatch ();
573
- assertTrue ( indexer .maybeTriggerAsyncJob (System .currentTimeMillis ()));
569
+ assertBusy (() -> indexer .maybeTriggerAsyncJob (System .currentTimeMillis ()));
574
570
assertThat (indexer .stop (), equalTo (IndexerState .STOPPING ));
575
571
assertThat (indexer .getState (), Matchers .either (Matchers .is (IndexerState .STOPPING )).or (Matchers .is (IndexerState .STOPPED )));
576
572
latch .countDown ();
0 commit comments