From 87f7b9c0f967d2514d26a0f11dbe601eab284327 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sun, 10 Dec 2017 13:04:22 -0500 Subject: [PATCH] Speed up rejected execution contains node name test This commit addresses slowness in the test that a rejected execution contains the node name. The slowness came from setting the count on a countdown latch too high (two in the case of the search thread pool) where there would never be a second countdown on the latch. This means that when then test node is shutting down, closing the node would have to wait a full ten seconds before forcefully terminating the thread pool. This commit fixes the issue so that the node can close immediately, shaving ten seconds off the run time of the test. Relates #27663 --- .../common/util/concurrent/EsThreadPoolExecutorTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutorTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutorTests.java index 9b9aa50bd16..b6110a85ece 100644 --- a/core/src/test/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutorTests.java +++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutorTests.java @@ -50,7 +50,7 @@ public class EsThreadPoolExecutorTests extends ESSingleNodeTestCase { } private void runThreadPoolExecutorTest(final int fill, final String executor) { - final CountDownLatch latch = new CountDownLatch(fill); + final CountDownLatch latch = new CountDownLatch(1); for (int i = 0; i < fill; i++) { node().injector().getInstance(ThreadPool.class).executor(executor).execute(() -> { try { @@ -64,12 +64,12 @@ public class EsThreadPoolExecutorTests extends ESSingleNodeTestCase { final AtomicBoolean rejected = new AtomicBoolean(); node().injector().getInstance(ThreadPool.class).executor(executor).execute(new AbstractRunnable() { @Override - public void onFailure(Exception e) { + public void onFailure(final Exception e) { } @Override - public void onRejection(Exception e) { + public void onRejection(final Exception e) { rejected.set(true); assertThat(e, hasToString(containsString("name = es-thread-pool-executor-tests/" + executor + ", "))); }