Reduce test load in TaskManagerTests
This commit is contained in:
parent
87a10806ab
commit
ac432f6612
|
@ -45,6 +45,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Phaser;
|
import java.util.concurrent.Phaser;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -115,7 +116,7 @@ public class TaskManagerTests extends ESTestCase {
|
||||||
expectedCancelledTasks.add(task);
|
expectedCancelledTasks.add(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)));
|
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)), 30, TimeUnit.SECONDS);
|
||||||
for (FakeTcpChannel channel : channels) {
|
for (FakeTcpChannel channel : channels) {
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
|
@ -132,7 +133,7 @@ public class TaskManagerTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Set<Task> expectedCancelledTasks = ConcurrentCollections.newConcurrentSet();
|
Set<Task> 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++) {
|
for (int i = 0; i < channels.length; i++) {
|
||||||
channels[i] = new FakeTcpChannel();
|
channels[i] = new FakeTcpChannel();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +143,7 @@ public class TaskManagerTests extends ESTestCase {
|
||||||
String threadName = "thread-" + t;
|
String threadName = "thread-" + t;
|
||||||
threads[t] = new Thread(() -> {
|
threads[t] = new Thread(() -> {
|
||||||
phaser.arriveAndAwaitAdvance();
|
phaser.arriveAndAwaitAdvance();
|
||||||
int iterations = randomIntBetween(100, 1000);
|
int iterations = randomIntBetween(50, 500);
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
final FakeTcpChannel channel = randomFrom(channels);
|
final FakeTcpChannel channel = randomFrom(channels);
|
||||||
final Task task = taskManager.register("transport", "test", new CancellableRequest(threadName + ":" + i));
|
final Task task = taskManager.register("transport", "test", new CancellableRequest(threadName + ":" + i));
|
||||||
|
@ -161,7 +162,7 @@ public class TaskManagerTests extends ESTestCase {
|
||||||
for (Thread thread : threads) {
|
for (Thread thread : threads) {
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)));
|
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)), 1, TimeUnit.MINUTES);
|
||||||
assertThat(taskManager.numberOfChannelPendingTaskTrackers(), equalTo(0));
|
assertThat(taskManager.numberOfChannelPendingTaskTrackers(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue