From 78824cce81ef2a91c940b9b137bbfa45eada3fb2 Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Thu, 5 Sep 2019 21:59:37 +0200 Subject: [PATCH] reuse mock client to avoid probles with thread context closed errors (#46398) --- ...ameTransformCheckpointServiceNodeTests.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/checkpoint/DataFrameTransformCheckpointServiceNodeTests.java b/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/checkpoint/DataFrameTransformCheckpointServiceNodeTests.java index fe6cc7c7525ad..2882505163013 100644 --- a/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/checkpoint/DataFrameTransformCheckpointServiceNodeTests.java +++ b/x-pack/plugin/data-frame/src/test/java/org/elasticsearch/xpack/dataframe/checkpoint/DataFrameTransformCheckpointServiceNodeTests.java @@ -50,7 +50,7 @@ import org.elasticsearch.xpack.dataframe.DataFrameSingleNodeTestCase; import org.elasticsearch.xpack.dataframe.notifications.DataFrameAuditor; import org.elasticsearch.xpack.dataframe.persistence.DataFrameTransformsConfigManager; -import org.junit.After; +import org.junit.AfterClass; import org.junit.Before; import java.nio.file.Path; @@ -67,8 +67,12 @@ public class DataFrameTransformCheckpointServiceNodeTests extends DataFrameSingleNodeTestCase { + // re-use the mock client for the whole test suite as the underlying thread pool and the + // corresponding context if recreated cause unreliable test execution + // see https://github.com/elastic/elasticsearch/issues/45238 and https://github.com/elastic/elasticsearch/issues/42577 + private static MockClientForCheckpointing mockClientForCheckpointing = null; + private DataFrameTransformsConfigManager transformsConfigManager; - private MockClientForCheckpointing mockClientForCheckpointing; private DataFrameTransformsCheckpointService transformsCheckpointService; private class MockClientForCheckpointing extends NoOpClient { @@ -121,18 +125,22 @@ void doExecute(ActionType action, Request request, ActionListener