Skip to content

Commit 617a56a

Browse files
lktsalbertzaharovits
authored andcommitted
Improve reliability of RollupIndexerStateTests#testMultipleJobTriggering (#110397)
1 parent ce14fde commit 617a56a

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ tests:
4444
- class: "org.elasticsearch.xpack.inference.InferenceCrudIT"
4545
issue: "https://github.com/elastic/elasticsearch/issues/109391"
4646
method: "testDeleteEndpointWhileReferencedByPipeline"
47-
- class: "org.elasticsearch.xpack.rollup.job.RollupIndexerStateTests"
48-
issue: "https://github.com/elastic/elasticsearch/issues/109627"
49-
method: "testMultipleJobTriggering"
5047
- class: "org.elasticsearch.xpack.test.rest.XPackRestIT"
5148
issue: "https://github.com/elastic/elasticsearch/issues/109687"
5249
method: "test {p0=sql/translate/Translate SQL}"

x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/job/RollupIndexerStateTests.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,18 +549,14 @@ public void testMultipleJobTriggering() throws Exception {
549549
AtomicReference<IndexerState> state = new AtomicReference<>(IndexerState.STOPPED);
550550
final ThreadPool threadPool = new TestThreadPool(getTestName());
551551
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);
559553
indexer.start();
560554
for (int i = 0; i < 5; i++) {
561555
final CountDownLatch latch = indexer.newLatch();
562556
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()));
564560
assertThat(indexer.getState(), equalTo(IndexerState.INDEXING));
565561
assertFalse(indexer.maybeTriggerAsyncJob(System.currentTimeMillis()));
566562
assertThat(indexer.getState(), equalTo(IndexerState.INDEXING));
@@ -570,7 +566,7 @@ protected void onAbort() {
570566
assertThat(indexer.getStats().getNumPages(), equalTo((long) i + 1));
571567
}
572568
final CountDownLatch latch = indexer.newLatch();
573-
assertTrue(indexer.maybeTriggerAsyncJob(System.currentTimeMillis()));
569+
assertBusy(() -> indexer.maybeTriggerAsyncJob(System.currentTimeMillis()));
574570
assertThat(indexer.stop(), equalTo(IndexerState.STOPPING));
575571
assertThat(indexer.getState(), Matchers.either(Matchers.is(IndexerState.STOPPING)).or(Matchers.is(IndexerState.STOPPED)));
576572
latch.countDown();

0 commit comments

Comments
 (0)