Skip to content

Commit

Permalink
Add extra logging to PrioritizedThrottledTaskRunnerTests#assertNoRunn…
Browse files Browse the repository at this point in the history
…ingTasks (#93174)

This should help debugging #92910 and rule out possible environmental
issues, such us slowness creating threads due to an overloaded CI
worker.
  • Loading branch information
fcofdez authored Jan 24, 2023
1 parent 0c1e7db commit 8ae886a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,14 @@ private int getRandomPriority() {
}

private void assertNoRunningTasks(PrioritizedThrottledTaskRunner<TestTask> taskRunner) {
logger.info("--> ensure that there are no running tasks in the executor. Max number of threads [{}]", maxThreads);
final var barrier = new CyclicBarrier(maxThreads + 1);
for (int i = 0; i < maxThreads; i++) {
executor.execute(() -> awaitBarrier(barrier));
executor.execute(() -> {
logger.info("--> await until barrier is released");
awaitBarrier(barrier);
logger.info("--> the barrier is released");
});
}
awaitBarrier(barrier);
assertThat(taskRunner.runningTasks(), equalTo(0));
Expand Down

0 comments on commit 8ae886a

Please sign in to comment.