check position before and after latch (#42623)
check position before and after latch #fixes 42084
This commit is contained in:
parent
e54e74852a
commit
ace96a2b6e
|
@ -225,7 +225,6 @@ public class AsyncTwoPhaseIndexerTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/42084")
|
|
||||||
public void testStateMachine() throws Exception {
|
public void testStateMachine() throws Exception {
|
||||||
AtomicReference<IndexerState> state = new AtomicReference<>(IndexerState.STOPPED);
|
AtomicReference<IndexerState> state = new AtomicReference<>(IndexerState.STOPPED);
|
||||||
final ExecutorService executor = Executors.newFixedThreadPool(1);
|
final ExecutorService executor = Executors.newFixedThreadPool(1);
|
||||||
|
@ -236,10 +235,11 @@ public class AsyncTwoPhaseIndexerTests extends ESTestCase {
|
||||||
assertThat(indexer.getState(), equalTo(IndexerState.STARTED));
|
assertThat(indexer.getState(), equalTo(IndexerState.STARTED));
|
||||||
assertTrue(indexer.maybeTriggerAsyncJob(System.currentTimeMillis()));
|
assertTrue(indexer.maybeTriggerAsyncJob(System.currentTimeMillis()));
|
||||||
assertThat(indexer.getState(), equalTo(IndexerState.INDEXING));
|
assertThat(indexer.getState(), equalTo(IndexerState.INDEXING));
|
||||||
|
assertTrue(awaitBusy(() -> indexer.getPosition() == 2));
|
||||||
countDownLatch.countDown();
|
countDownLatch.countDown();
|
||||||
|
|
||||||
assertThat(indexer.getPosition(), equalTo(2));
|
|
||||||
assertTrue(awaitBusy(() -> isFinished.get()));
|
assertTrue(awaitBusy(() -> isFinished.get()));
|
||||||
|
assertThat(indexer.getPosition(), equalTo(3));
|
||||||
|
|
||||||
assertFalse(isStopped.get());
|
assertFalse(isStopped.get());
|
||||||
assertThat(indexer.getStep(), equalTo(6));
|
assertThat(indexer.getStep(), equalTo(6));
|
||||||
assertThat(indexer.getStats().getNumInvocations(), equalTo(1L));
|
assertThat(indexer.getStats().getNumInvocations(), equalTo(1L));
|
||||||
|
|
Loading…
Reference in New Issue