From 9f7be70f7af27e64e5f94479712ccefb98c96bc0 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 6 Jun 2019 14:05:17 +0200 Subject: [PATCH] Fix testPendingTasks (#42922) Fixes a race in the test which can be reliably reproduced by adding Thread.sleep(100) to the end of IndicesService.processPendingDeletes Closes #18747 --- .../java/org/elasticsearch/indices/IndicesServiceTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java index 6aa33b347ea..07207264262 100644 --- a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java @@ -330,8 +330,10 @@ public class IndicesServiceTests extends ESSingleNodeTestCase { fail(e.getMessage()); } }); - assertThat(indicesService.hasUncompletedPendingDeletes(), equalTo(hasBogus)); // "bogus" index has not been removed - assertFalse(shardPath.exists()); + assertBusy(() -> { + assertThat(indicesService.hasUncompletedPendingDeletes(), equalTo(hasBogus)); // "bogus" index has not been removed + assertFalse(shardPath.exists()); + }); } public void testVerifyIfIndexContentDeleted() throws Exception {