Skip to content

Commit

Permalink
Reduce test load in TaskManagerTests
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed May 14, 2020
1 parent 4b47e84 commit c24885d
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
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;
Expand Down Expand Up @@ -115,7 +116,7 @@ void cancelTaskAndDescendants(CancellableTask task, String reason, boolean waitF
expectedCancelledTasks.add(task);
}
}
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)));
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)), 30, TimeUnit.SECONDS);
for (FakeTcpChannel channel : channels) {
channel.close();
}
Expand All @@ -132,7 +133,7 @@ void cancelTaskAndDescendants(CancellableTask task, String reason, boolean waitF
}
});
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++) {
channels[i] = new FakeTcpChannel();
}
Expand All @@ -142,7 +143,7 @@ void cancelTaskAndDescendants(CancellableTask task, String reason, boolean waitF
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));
Expand All @@ -161,7 +162,7 @@ void cancelTaskAndDescendants(CancellableTask task, String reason, boolean waitF
for (Thread thread : threads) {
thread.join();
}
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)));
assertBusy(() -> assertThat(cancelledTasks, equalTo(expectedCancelledTasks)), 1, TimeUnit.MINUTES);
assertThat(taskManager.numberOfChannelPendingTaskTrackers(), equalTo(0));
}

Expand Down

0 comments on commit c24885d

Please sign in to comment.