diff --git a/server/src/test/java/org/elasticsearch/tasks/TaskManagerTests.java b/server/src/test/java/org/elasticsearch/tasks/TaskManagerTests.java index 51bc2315535..60b06d99dba 100644 --- a/server/src/test/java/org/elasticsearch/tasks/TaskManagerTests.java +++ b/server/src/test/java/org/elasticsearch/tasks/TaskManagerTests.java @@ -45,6 +45,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Phaser; +import java.util.concurrent.TimeUnit; import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; @@ -115,7 +116,7 @@ public class TaskManagerTests extends ESTestCase { expectedCancelledTasks.add(task); } } - assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks))); + assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)), 30, TimeUnit.SECONDS); for (FakeTcpChannel channel : channels) { channel.close(); } @@ -132,7 +133,7 @@ public class TaskManagerTests extends ESTestCase { } }); Set expectedCancelledTasks = ConcurrentCollections.newConcurrentSet(); - FakeTcpChannel[] channels = new FakeTcpChannel[randomIntBetween(2, 20)]; + FakeTcpChannel[] channels = new FakeTcpChannel[randomIntBetween(1, 10)]; for (int i = 0; i < channels.length; i++) { channels[i] = new FakeTcpChannel(); } @@ -142,7 +143,7 @@ public class TaskManagerTests extends ESTestCase { String threadName = "thread-" + t; threads[t] = new Thread(() -> { phaser.arriveAndAwaitAdvance(); - int iterations = randomIntBetween(100, 1000); + int iterations = randomIntBetween(50, 500); for (int i = 0; i < iterations; i++) { final FakeTcpChannel channel = randomFrom(channels); final Task task = taskManager.register("transport", "test", new CancellableRequest(threadName + ":" + i)); @@ -161,7 +162,7 @@ public class TaskManagerTests extends ESTestCase { for (Thread thread : threads) { thread.join(); } - assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks))); + assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)), 1, TimeUnit.MINUTES); assertThat(taskManager.numberOfChannelPendingTaskTrackers(), equalTo(0)); }