Search in sources :

Example 6 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class SelectStatementAnalyzerTest method init.

@Before
public void init() throws Exception {
    DocTableInfo fooUserTableInfo = TestingTableInfo.builder(new TableIdent("foo", "users"), SHARD_ROUTING).add("id", DataTypes.LONG, null).add("name", DataTypes.STRING, null).addPrimaryKey("id").build();
    DocTableInfoFactory fooTableFactory = new TestingDocTableInfoFactory(ImmutableMap.of(fooUserTableInfo.ident(), fooUserTableInfo));
    ClusterService clusterService = new NoopClusterService();
    sqlExecutor = SQLExecutor.builder(clusterService).enableDefaultTables().addSchema(new DocSchemaInfo("foo", clusterService, fooTableFactory)).build();
}
Also used : DocTableInfo(io.crate.metadata.doc.DocTableInfo) DocSchemaInfo(io.crate.metadata.doc.DocSchemaInfo) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ClusterService(org.elasticsearch.cluster.ClusterService) TestingDocTableInfoFactory(io.crate.metadata.doc.TestingDocTableInfoFactory) TableIdent(io.crate.metadata.TableIdent) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) DocTableInfoFactory(io.crate.metadata.doc.DocTableInfoFactory) TestingDocTableInfoFactory(io.crate.metadata.doc.TestingDocTableInfoFactory) Before(org.junit.Before)

Example 7 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class SysShardsExpressionsTest method prepare.

@Before
public void prepare() throws Exception {
    ClusterService clusterService = new NoopClusterService();
    indexShard = mockIndexShard();
    schemas = new Schemas(Settings.EMPTY, ImmutableMap.of("sys", new SysSchemaInfo(clusterService)), clusterService, new DocSchemaInfoFactory(new TestingDocTableInfoFactory(Collections.emptyMap())));
    ShardReferenceResolver shardRefResolver = new ShardReferenceResolver(clusterService, schemas, indexShard);
    resolver = new RecoveryShardReferenceResolver(shardRefResolver, indexShard);
}
Also used : SysSchemaInfo(io.crate.metadata.sys.SysSchemaInfo) RecoveryShardReferenceResolver(io.crate.metadata.shard.RecoveryShardReferenceResolver) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ClusterService(org.elasticsearch.cluster.ClusterService) DocSchemaInfoFactory(io.crate.metadata.doc.DocSchemaInfoFactory) TestingDocTableInfoFactory(io.crate.metadata.doc.TestingDocTableInfoFactory) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ShardReferenceResolver(io.crate.metadata.shard.ShardReferenceResolver) RecoveryShardReferenceResolver(io.crate.metadata.shard.RecoveryShardReferenceResolver) Before(org.junit.Before)

Example 8 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class BulkRetryCoordinatorPoolTest method prepare.

@Before
public void prepare() {
    MetaData metaData = MetaData.builder().put(IndexMetaData.builder(TEST_INDEX).settings(settings(Version.CURRENT)).numberOfShards(3).numberOfReplicas(0)).build();
    RoutingTable routingTable = RoutingTable.builder().addAsNew(metaData.index(TEST_INDEX)).build();
    ClusterState state = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build();
    state = ClusterState.builder(state).nodes(DiscoveryNodes.builder().put(newNode(NODE_IDS[0])).localNodeId(NODE_IDS[0])).build();
    AllocationService allocationService = createAllocationService();
    routingTable = allocationService.reroute(state, "test").routingTable();
    state = ClusterState.builder(state).routingTable(routingTable).build();
    ClusterService clusterService = new NoopClusterService(state);
    this.state = state;
    pool = new BulkRetryCoordinatorPool(Settings.EMPTY, clusterService, mock(ThreadPool.class));
    pool.start();
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ClusterService(org.elasticsearch.cluster.ClusterService) RoutingTable(org.elasticsearch.cluster.routing.RoutingTable) MetaData(org.elasticsearch.cluster.metadata.MetaData) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) AllocationService(org.elasticsearch.cluster.routing.allocation.AllocationService) ESAllocationTestCase.createAllocationService(org.elasticsearch.test.ESAllocationTestCase.createAllocationService) Before(org.junit.Before)

Example 9 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class DecommissioningServiceTest method setUp.

@Before
public void setUp() throws Exception {
    NodeSettingsService settingsService = new NodeSettingsService(Settings.EMPTY);
    threadPool = mock(ThreadPool.class, Answers.RETURNS_MOCKS.get());
    jobsLogs = new JobsLogs(() -> true);
    sqlOperations = mock(SQLOperations.class, Answers.RETURNS_MOCKS.get());
    decommissioningService = new TestableDecommissioningService(Settings.EMPTY, new NoopClusterService(), jobsLogs, threadPool, settingsService, sqlOperations, mock(TransportClusterHealthAction.class), mock(TransportClusterUpdateSettingsAction.class));
}
Also used : ThreadPool(org.elasticsearch.threadpool.ThreadPool) JobsLogs(io.crate.operation.collect.stats.JobsLogs) NodeSettingsService(org.elasticsearch.node.settings.NodeSettingsService) SQLOperations(io.crate.action.sql.SQLOperations) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Before(org.junit.Before)

Example 10 with NoopClusterService

use of org.elasticsearch.test.cluster.NoopClusterService in project crate by crate.

the class DocTableInfoBuilderTest method testNoTableInfoFromOrphanedPartition.

@Test
public void testNoTableInfoFromOrphanedPartition() throws Exception {
    String schemaName = randomSchema();
    PartitionName partitionName = new PartitionName(schemaName, "test", Collections.singletonList(new BytesRef("boo")));
    IndexMetaData.Builder indexMetaDataBuilder = IndexMetaData.builder(partitionName.asIndexName()).settings(Settings.builder().put("index.version.created", Version.CURRENT).build()).numberOfReplicas(0).numberOfShards(5).putMapping(Constants.DEFAULT_MAPPING_TYPE, "{" + "  \"default\": {" + "    \"properties\":{" + "      \"id\": {" + "         \"type\": \"integer\"," + "         \"index\": \"not_analyzed\"" + "      }" + "    }" + "  }" + "}");
    MetaData metaData = MetaData.builder().put(indexMetaDataBuilder).build();
    NoopClusterService clusterService = new NoopClusterService(ClusterState.builder(ClusterName.DEFAULT).metaData(metaData).build());
    DocTableInfoBuilder builder = new DocTableInfoBuilder(functions, new TableIdent(schemaName, "test"), clusterService, new IndexNameExpressionResolver(Settings.EMPTY), mock(TransportPutIndexTemplateAction.class), executorService, false);
    expectedException.expect(TableUnknownException.class);
    expectedException.expectMessage(String.format(Locale.ENGLISH, "Table '%s.test' unknown", schemaName));
    builder.build();
}
Also used : PartitionName(io.crate.metadata.PartitionName) MetaData(org.elasticsearch.cluster.metadata.MetaData) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) TransportPutIndexTemplateAction(org.elasticsearch.action.admin.indices.template.put.TransportPutIndexTemplateAction) TableIdent(io.crate.metadata.TableIdent) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) BytesRef(org.apache.lucene.util.BytesRef) IndexMetaData(org.elasticsearch.cluster.metadata.IndexMetaData) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

NoopClusterService (org.elasticsearch.test.cluster.NoopClusterService)27 Before (org.junit.Before)19 ClusterService (org.elasticsearch.cluster.ClusterService)8 TableIdent (io.crate.metadata.TableIdent)7 Test (org.junit.Test)7 ClusterState (org.elasticsearch.cluster.ClusterState)6 CrateUnitTest (io.crate.test.integration.CrateUnitTest)5 TestingTableInfo (io.crate.metadata.table.TestingTableInfo)4 SQLExecutor (io.crate.testing.SQLExecutor)4 ClusterName (org.elasticsearch.cluster.ClusterName)4 MetaData (org.elasticsearch.cluster.metadata.MetaData)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 JobContextService (io.crate.jobs.JobContextService)3 JobsLogs (io.crate.operation.collect.stats.JobsLogs)3 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)3 TransportService (org.elasticsearch.transport.TransportService)3 PartitionName (io.crate.metadata.PartitionName)2 Routing (io.crate.metadata.Routing)2 TestingDocTableInfoFactory (io.crate.metadata.doc.TestingDocTableInfoFactory)2 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)2