|
@@ -45,11 +45,13 @@ import org.elasticsearch.common.settings.ClusterSettings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
import org.elasticsearch.common.util.concurrent.AtomicArray;
|
|
|
+import org.elasticsearch.common.util.concurrent.EsExecutors;
|
|
|
import org.elasticsearch.index.IndexNotFoundException;
|
|
|
import org.elasticsearch.index.IndexSettings;
|
|
|
import org.elasticsearch.ingest.IngestService;
|
|
|
import org.elasticsearch.tasks.Task;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
+import org.elasticsearch.threadpool.ThreadPool;
|
|
|
import org.elasticsearch.transport.TransportResponseHandler;
|
|
|
import org.elasticsearch.transport.TransportService;
|
|
|
import org.junit.Before;
|
|
@@ -61,6 +63,7 @@ import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.function.BiConsumer;
|
|
|
import java.util.function.Consumer;
|
|
@@ -68,6 +71,7 @@ import java.util.function.Consumer;
|
|
|
import static org.hamcrest.Matchers.containsString;
|
|
|
import static org.hamcrest.Matchers.sameInstance;
|
|
|
import static org.mockito.Matchers.any;
|
|
|
+import static org.mockito.Matchers.anyString;
|
|
|
import static org.mockito.Matchers.eq;
|
|
|
import static org.mockito.Mockito.doAnswer;
|
|
|
import static org.mockito.Mockito.mock;
|
|
@@ -92,6 +96,7 @@ public class TransportBulkActionIngestTests extends ESTestCase {
|
|
|
TransportService transportService;
|
|
|
ClusterService clusterService;
|
|
|
IngestService ingestService;
|
|
|
+ ThreadPool threadPool;
|
|
|
|
|
|
/** Arguments to callbacks we want to capture, but which require generics, so we must use @Captor */
|
|
|
@Captor
|
|
@@ -126,7 +131,7 @@ public class TransportBulkActionIngestTests extends ESTestCase {
|
|
|
boolean indexCreated = true; // If set to false, will be set to true by call to createIndex
|
|
|
|
|
|
TestTransportBulkAction() {
|
|
|
- super(null, transportService, clusterService, ingestService,
|
|
|
+ super(threadPool, transportService, clusterService, ingestService,
|
|
|
null, null, new ActionFilters(Collections.emptySet()), null,
|
|
|
new AutoCreateIndex(
|
|
|
SETTINGS, new ClusterSettings(SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
|
|
@@ -163,6 +168,9 @@ public class TransportBulkActionIngestTests extends ESTestCase {
|
|
|
@Before
|
|
|
public void setupAction() {
|
|
|
// initialize captors, which must be members to use @Capture because of generics
|
|
|
+ threadPool = mock(ThreadPool.class);
|
|
|
+ final ExecutorService direct = EsExecutors.newDirectExecutorService();
|
|
|
+ when(threadPool.executor(anyString())).thenReturn(direct);
|
|
|
MockitoAnnotations.initMocks(this);
|
|
|
// setup services that will be called by action
|
|
|
transportService = mock(TransportService.class);
|