Skip to content

Commit 8697eae

Browse files
committed
Fix
1 parent 902f5c8 commit 8697eae

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ private void blockWriteCoordinationThreadPool(CountDownLatch blockingLatch) {
423423
});
424424
}
425425

426-
public void testDispatchesToWriteCoordinationThreadPoolOnce() {
426+
public void testDispatchesToWriteCoordinationThreadPoolOnce() throws Exception {
427427
BulkRequest bulkRequest = new BulkRequest().add(new IndexRequest("index").id("id").source(Collections.emptyMap()));
428428
PlainActionFuture<BulkResponse> future = new PlainActionFuture<>();
429429
ThreadPoolStats.Stats stats = threadPool.stats()
@@ -435,10 +435,22 @@ public void testDispatchesToWriteCoordinationThreadPoolOnce() {
435435
assertThat(stats.completed(), equalTo(0L));
436436
ActionTestUtils.execute(bulkAction, null, bulkRequest, future);
437437
future.actionGet();
438-
stats = threadPool.stats().stats().stream().filter(s -> s.name().equals(ThreadPool.Names.WRITE_COORDINATION)).findAny().get();
439-
// Will increment twice because it will dispatch on the first coordination attempt. And then dispatch a second time after the index
440-
// is created.
441-
assertThat(stats.completed(), equalTo(2L));
438+
439+
assertBusy(() -> {
440+
// Will increment twice because it will dispatch on the first coordination attempt. And then dispatch a second time after the
441+
// index
442+
// is created.
443+
assertThat(
444+
threadPool.stats()
445+
.stats()
446+
.stream()
447+
.filter(s -> s.name().equals(ThreadPool.Names.WRITE_COORDINATION))
448+
.findAny()
449+
.get()
450+
.completed(),
451+
equalTo(2L)
452+
);
453+
});
442454
}
443455

444456
public void testRejectCoordination() {

0 commit comments

Comments
 (0)