Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove flaky queue resizing tests #78634

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,64 +110,6 @@ public void testAutoQueueSizingDown() throws Exception {
executor.awaitTermination(10, TimeUnit.SECONDS);
}

public void testAutoQueueSizingWithMin() throws Exception {
ThreadContext context = new ThreadContext(Settings.EMPTY);
ResizableBlockingQueue<Runnable> queue =
new ResizableBlockingQueue<>(ConcurrentCollections.<Runnable>newBlockingQueue(),
5000);

int threads = randomIntBetween(1, 5);
int measureWindow = randomIntBetween(10, 100);
int min = randomIntBetween(4981, 4999);
logger.info("--> auto-queue with a measurement window of {} tasks", measureWindow);
QueueResizingEsThreadPoolExecutor executor =
new QueueResizingEsThreadPoolExecutor(
"test-threadpool", threads, threads, 1000,
TimeUnit.MILLISECONDS, queue, min, 100000, slowWrapper(), measureWindow, TimeValue.timeValueMillis(1),
EsExecutors.daemonThreadFactory("queuetest"), new EsAbortPolicy(), context);
executor.prestartAllCoreThreads();
logger.info("--> executor: {}", executor);

// Execute a task multiple times that takes 1m
executeTask(executor, (measureWindow * 5));

// The queue capacity should decrease, but no lower than the minimum
assertBusy(() -> {
assertThat(queue.capacity(), equalTo(min));
});
executor.shutdown();
executor.awaitTermination(10, TimeUnit.SECONDS);
}

public void testAutoQueueSizingWithMax() throws Exception {
ThreadContext context = new ThreadContext(Settings.EMPTY);
ResizableBlockingQueue<Runnable> queue =
new ResizableBlockingQueue<>(ConcurrentCollections.<Runnable>newBlockingQueue(),
5000);

int threads = randomIntBetween(1, 5);
int measureWindow = randomIntBetween(10, 100);
int max = randomIntBetween(5010, 5024);
logger.info("--> auto-queue with a measurement window of {} tasks", measureWindow);
QueueResizingEsThreadPoolExecutor executor =
new QueueResizingEsThreadPoolExecutor(
"test-threadpool", threads, threads, 1000,
TimeUnit.MILLISECONDS, queue, 10, max, fastWrapper(), measureWindow, TimeValue.timeValueMillis(1),
EsExecutors.daemonThreadFactory("queuetest"), new EsAbortPolicy(), context);
executor.prestartAllCoreThreads();
logger.info("--> executor: {}", executor);

// Execute a task multiple times that takes 1ms
executeTask(executor, measureWindow * 3);

// The queue capacity should increase, but no higher than the maximum
assertBusy(() -> {
assertThat(queue.capacity(), equalTo(max));
});
executor.shutdown();
executor.awaitTermination(10, TimeUnit.SECONDS);
}

public void testExecutionEWMACalculation() throws Exception {
ThreadContext context = new ThreadContext(Settings.EMPTY);
ResizableBlockingQueue<Runnable> queue =
Expand Down