Search in sources :

Example 11 with CapturingTransport

use of org.elasticsearch.test.transport.CapturingTransport in project elasticsearch by elastic.

the class TransportInstanceSingleOperationActionTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    transport = new CapturingTransport();
    clusterService = createClusterService(THREAD_POOL);
    transportService = new TransportService(clusterService.getSettings(), transport, THREAD_POOL, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    action = new TestTransportInstanceSingleOperationAction(Settings.EMPTY, "indices:admin/test", transportService, new ActionFilters(new HashSet<ActionFilter>()), new MyResolver(), Request::new);
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) BeforeClass(org.junit.BeforeClass) ShardIterator(org.elasticsearch.cluster.routing.ShardIterator) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) ClusterService(org.elasticsearch.cluster.service.ClusterService) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) IndicesRequest(org.elasticsearch.action.IndicesRequest) TimeoutException(java.util.concurrent.TimeoutException) HashMap(java.util.HashMap) ClusterBlocks(org.elasticsearch.cluster.block.ClusterBlocks) ShardRoutingState(org.elasticsearch.cluster.routing.ShardRoutingState) Supplier(java.util.function.Supplier) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) HashSet(java.util.HashSet) ClusterState(org.elasticsearch.cluster.ClusterState) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) Settings(org.elasticsearch.common.settings.Settings) ClusterBlock(org.elasticsearch.cluster.block.ClusterBlock) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException) TimeValue(org.elasticsearch.common.unit.TimeValue) After(org.junit.After) Map(java.util.Map) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) ClusterBlockLevel(org.elasticsearch.cluster.block.ClusterBlockLevel) ClusterStateCreationUtils(org.elasticsearch.action.support.replication.ClusterStateCreationUtils) Before(org.junit.Before) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) AfterClass(org.junit.AfterClass) ActionFilter(org.elasticsearch.action.support.ActionFilter) ActionFilters(org.elasticsearch.action.support.ActionFilters) ActionResponse(org.elasticsearch.action.ActionResponse) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ExceptionsHelper(org.elasticsearch.ExceptionsHelper) RestStatus(org.elasticsearch.rest.RestStatus) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) TransportException(org.elasticsearch.transport.TransportException) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) ActionListener(org.elasticsearch.action.ActionListener) TransportService(org.elasticsearch.transport.TransportService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ActionFilters(org.elasticsearch.action.support.ActionFilters) ActionFilter(org.elasticsearch.action.support.ActionFilter) Before(org.junit.Before)

Example 12 with CapturingTransport

use of org.elasticsearch.test.transport.CapturingTransport in project elasticsearch by elastic.

the class ClusterStateHealthTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    clusterService = createClusterService(threadPool);
    transportService = new TransportService(clusterService.getSettings(), new CapturingTransport(), threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
}
Also used : MetaData(org.elasticsearch.cluster.metadata.MetaData) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ClusterState(org.elasticsearch.cluster.ClusterState) ClusterStateUpdateTask(org.elasticsearch.cluster.ClusterStateUpdateTask) Settings(org.elasticsearch.common.settings.Settings) After(org.junit.After) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) RoutingTableGenerator(org.elasticsearch.cluster.routing.RoutingTableGenerator) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ClusterName(org.elasticsearch.cluster.ClusterName) AfterClass(org.junit.AfterClass) ActionFilters(org.elasticsearch.action.support.ActionFilters) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) UUIDs(org.elasticsearch.common.UUIDs) Set(java.util.Set) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) ObjectCursor(com.carrotsearch.hppc.cursors.ObjectCursor) Sets(org.elasticsearch.common.util.set.Sets) RecoverySource(org.elasticsearch.cluster.routing.RecoverySource) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Version(org.elasticsearch.Version) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) IndexRoutingTable(org.elasticsearch.cluster.routing.IndexRoutingTable) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) ImmutableOpenIntMap(org.elasticsearch.common.collect.ImmutableOpenIntMap) Matchers.is(org.hamcrest.Matchers.is) TransportClusterHealthAction(org.elasticsearch.action.admin.cluster.health.TransportClusterHealthAction) IntObjectCursor(com.carrotsearch.hppc.cursors.IntObjectCursor) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) BeforeClass(org.junit.BeforeClass) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ClusterService(org.elasticsearch.cluster.service.ClusterService) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) Before(org.junit.Before) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) TestGatewayAllocator(org.elasticsearch.test.gateway.TestGatewayAllocator) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) IOException(java.io.IOException) UnassignedInfo(org.elasticsearch.cluster.routing.UnassignedInfo) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) RoutingTable(org.elasticsearch.cluster.routing.RoutingTable) StreamInput(org.elasticsearch.common.io.stream.StreamInput) LocalClusterUpdateTask(org.elasticsearch.cluster.LocalClusterUpdateTask) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) TransportService(org.elasticsearch.transport.TransportService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) Before(org.junit.Before)

Example 13 with CapturingTransport

use of org.elasticsearch.test.transport.CapturingTransport in project elasticsearch by elastic.

the class GlobalCheckpointSyncActionTests method setUp.

public void setUp() throws Exception {
    super.setUp();
    threadPool = new TestThreadPool(getClass().getName());
    transport = new CapturingTransport();
    clusterService = createClusterService(threadPool);
    transportService = new TransportService(clusterService.getSettings(), transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, boundAddress -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    shardStateAction = new ShardStateAction(Settings.EMPTY, clusterService, transportService, null, null, threadPool);
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) ActionFilters(org.elasticsearch.action.support.ActionFilters) Transport(org.elasticsearch.transport.Transport) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) IndexService(org.elasticsearch.index.IndexService) IndexShard(org.elasticsearch.index.shard.IndexShard) ClusterService(org.elasticsearch.cluster.service.ClusterService) IOUtils(org.apache.lucene.util.IOUtils) Index(org.elasticsearch.index.Index) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) Mockito.verify(org.mockito.Mockito.verify) Settings(org.elasticsearch.common.settings.Settings) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) Translog(org.elasticsearch.index.translog.Translog) ThreadPool(org.elasticsearch.threadpool.ThreadPool) IndicesService(org.elasticsearch.indices.IndicesService) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) Collections(java.util.Collections) Mockito.when(org.elasticsearch.mock.orig.Mockito.when) Mockito.mock(org.mockito.Mockito.mock) TransportService(org.elasticsearch.transport.TransportService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool)

Example 14 with CapturingTransport

use of org.elasticsearch.test.transport.CapturingTransport in project crate by crate.

the class BlobHeadRequestHandlerTests method setUpResources.

@Before
public void setUpResources() throws Exception {
    threadPool = new TestThreadPool(getClass().getName());
    var transport = new CapturingTransport() {

        @Override
        protected void onSendRequest(long requestId, String action, TransportRequest request, DiscoveryNode node) {
            super.onSendRequest(requestId, action, request, node);
            handleResponse(requestId, TransportResponse.Empty.INSTANCE);
        }
    };
    clusterService = ClusterServiceUtils.createClusterService(threadPool);
    transportService = transport.createTransportService(clusterService.getSettings(), threadPool, boundAddress -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
}
Also used : TransportRequest(org.elasticsearch.transport.TransportRequest) ClusterService(org.elasticsearch.cluster.service.ClusterService) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TransportResponse(org.elasticsearch.transport.TransportResponse) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) DigestBlob(io.crate.blob.DigestBlob) Before(org.junit.Before) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) EsExecutors(org.elasticsearch.common.util.concurrent.EsExecutors) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) UUID(java.util.UUID) File(java.io.File) Executors(java.util.concurrent.Executors) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) BlobTransferTarget(io.crate.blob.BlobTransferTarget) Version(org.elasticsearch.Version) ClusterServiceUtils(org.elasticsearch.test.ClusterServiceUtils) PutHeadChunkRunnable(io.crate.blob.transfer.PutHeadChunkRunnable) Mockito.mock(org.mockito.Mockito.mock) HeadChunkFileTooSmallException(io.crate.blob.transfer.HeadChunkFileTooSmallException) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) TransportRequest(org.elasticsearch.transport.TransportRequest) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) Before(org.junit.Before)

Example 15 with CapturingTransport

use of org.elasticsearch.test.transport.CapturingTransport in project crate by crate.

the class TransportVerifyShardBeforeCloseActionTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    indexShard = mock(IndexShard.class);
    when(indexShard.getActiveOperationsCount()).thenReturn(IndexShard.OPERATIONS_BLOCKED);
    ShardId shardId = new ShardId("index", "_na_", randomIntBetween(0, 3));
    when(indexShard.shardId()).thenReturn(shardId);
    clusterService = createClusterService(threadPool);
    clusterBlock = new ClusterBlock(INDEX_CLOSED_BLOCK_ID, UUIDs.randomBase64UUID(), "index preparing to close. Reopen the index to allow " + "writes again or retry closing the index to fully close the index.", false, false, false, RestStatus.FORBIDDEN, EnumSet.of(ClusterBlockLevel.WRITE));
    setState(clusterService, new ClusterState.Builder(clusterService.state()).blocks(ClusterBlocks.builder().blocks(clusterService.state().blocks()).addIndexBlock("index", clusterBlock).build()).build());
    transport = new CapturingTransport();
    TransportService transportService = transport.createTransportService(Settings.EMPTY, threadPool, x -> clusterService.localNode(), null);
    transportService.start();
    transportService.acceptIncomingRequests();
    ShardStateAction shardStateAction = new ShardStateAction(clusterService, transportService, null, null);
    action = new TransportVerifyShardBeforeCloseAction(Settings.EMPTY, transportService, clusterService, mock(IndicesService.class), mock(ThreadPool.class), shardStateAction);
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) ClusterBlock(org.elasticsearch.cluster.block.ClusterBlock) ClusterState(org.elasticsearch.cluster.ClusterState) TransportService(org.elasticsearch.transport.TransportService) IndexShard(org.elasticsearch.index.shard.IndexShard) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) Before(org.junit.Before)

Aggregations

CapturingTransport (org.elasticsearch.test.transport.CapturingTransport)20 TransportService (org.elasticsearch.transport.TransportService)20 ESTestCase (org.elasticsearch.test.ESTestCase)13 Settings (org.elasticsearch.common.settings.Settings)12 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)11 ThreadPool (org.elasticsearch.threadpool.ThreadPool)11 ClusterState (org.elasticsearch.cluster.ClusterState)10 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)10 ClusterService (org.elasticsearch.cluster.service.ClusterService)10 Before (org.junit.Before)10 ClusterServiceUtils.createClusterService (org.elasticsearch.test.ClusterServiceUtils.createClusterService)9 After (org.junit.After)9 TimeUnit (java.util.concurrent.TimeUnit)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)8 ActionListener (org.elasticsearch.action.ActionListener)8 ActionFilters (org.elasticsearch.action.support.ActionFilters)8 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)8 Collections (java.util.Collections)7 HashSet (java.util.HashSet)7 Version (org.elasticsearch.Version)7