diff --git a/server/src/test/java/org/elasticsearch/node/NodeTests.java b/server/src/test/java/org/elasticsearch/node/NodeTests.java index 6f6b89e31f1bb..2cd16d3db4efb 100644 --- a/server/src/test/java/org/elasticsearch/node/NodeTests.java +++ b/server/src/test/java/org/elasticsearch/node/NodeTests.java @@ -36,7 +36,6 @@ import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.MockHttpTransport; import org.elasticsearch.threadpool.ThreadPool; -import org.hamcrest.Matchers; import java.io.IOException; import java.nio.file.Path; @@ -44,12 +43,14 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; +import static org.hamcrest.Matchers.containsString; @LuceneTestCase.SuppressFileSystems(value = "ExtrasFS") public class NodeTests extends ESTestCase { @@ -179,9 +180,13 @@ public void testCloseRaceWithTaskExecution() throws Exception { } catch (InterruptedException e) { throw new AssertionError("interrupted while waiting", e); } - threadpool.executor(ThreadPool.Names.SEARCH).execute(() -> { - while (shouldRun.get()); - }); + try { + threadpool.executor(ThreadPool.Names.SEARCH).execute(() -> { + while (shouldRun.get()); + }); + } catch (RejectedExecutionException e) { + assertThat(e.getMessage(), containsString("[Terminated,")); + } }); Thread closeThread = new Thread(() -> { running.countDown(); @@ -267,7 +272,7 @@ public void testCloseOnLeakedIndexReaderReference() throws Exception { IllegalStateException e = expectThrows(IllegalStateException.class, () -> node.awaitClose(1, TimeUnit.DAYS)); searcher.close(); - assertThat(e.getMessage(), Matchers.containsString("Something is leaking index readers or store references")); + assertThat(e.getMessage(), containsString("Something is leaking index readers or store references")); } public void testCloseOnLeakedStoreReference() throws Exception { @@ -283,6 +288,6 @@ public void testCloseOnLeakedStoreReference() throws Exception { IllegalStateException e = expectThrows(IllegalStateException.class, () -> node.awaitClose(1, TimeUnit.DAYS)); shard.store().decRef(); - assertThat(e.getMessage(), Matchers.containsString("Something is leaking index readers or store references")); + assertThat(e.getMessage(), containsString("Something is leaking index readers or store references")); } }