Search in sources :

Example 16 with NoopClusterService

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

the class WhereClauseAnalyzerTest method init.

@Before
public void init() throws Exception {
    SQLExecutor.Builder builder = SQLExecutor.builder(new NoopClusterService());
    registerTables(builder);
    TestingTableInfo.Builder genInfo = TestingTableInfo.builder(new TableIdent(DocSchemaInfo.NAME, GENERATED_COL_TABLE_NAME), new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of())).add("ts", DataTypes.TIMESTAMP, null).add("x", DataTypes.INTEGER, null).add("y", DataTypes.LONG, null).addGeneratedColumn("day", DataTypes.TIMESTAMP, "date_trunc('day', ts)", true).addGeneratedColumn("minus_y", DataTypes.LONG, "y * -1", true).addGeneratedColumn("x_incr", DataTypes.LONG, "x + 1", false).addPartitions(new PartitionName("generated_col", Arrays.asList(new BytesRef("1420070400000"), new BytesRef("-1"))).asIndexName(), new PartitionName("generated_col", Arrays.asList(new BytesRef("1420156800000"), new BytesRef("-2"))).asIndexName());
    builder.addDocTable(genInfo);
    TableIdent ident = new TableIdent(DocSchemaInfo.NAME, DOUBLE_GEN_PARTITIONED_TABLE_NAME);
    TestingTableInfo.Builder doubleGenPartedInfo = TestingTableInfo.builder(ident, new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of())).add("x", DataTypes.INTEGER, null).addGeneratedColumn("x1", DataTypes.LONG, "x+1", true).addGeneratedColumn("x2", DataTypes.LONG, "x+2", true).addPartitions(new PartitionName(ident, Arrays.asList(new BytesRef("4"), new BytesRef("5"))).toString(), new PartitionName(ident, Arrays.asList(new BytesRef("5"), new BytesRef("6"))).toString());
    builder.addDocTable(doubleGenPartedInfo);
    e = builder.build();
}
Also used : Routing(io.crate.metadata.Routing) TableIdent(io.crate.metadata.TableIdent) TestingTableInfo(io.crate.metadata.table.TestingTableInfo) PartitionName(io.crate.metadata.PartitionName) SQLExecutor(io.crate.testing.SQLExecutor) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) BytesRef(org.apache.lucene.util.BytesRef) Before(org.junit.Before)

Example 17 with NoopClusterService

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

the class TestGlobalSysExpressions method prepare.

@Before
public void prepare() throws Exception {
    Injector injector = new ModulesBuilder().add(new SysClusterExpressionModule()).add((Module) binder -> {
        binder.bind(ClusterService.class).toInstance(new NoopClusterService());
        binder.bind(Settings.class).toInstance(Settings.EMPTY);
        binder.bind(ClusterName.class).toInstance(new ClusterName("cluster"));
        binder.bind(ClusterReferenceResolver.class).asEagerSingleton();
    }).createInjector();
    resolver = injector.getInstance(ClusterReferenceResolver.class);
}
Also used : NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ClusterService(org.elasticsearch.cluster.ClusterService) SysClusterExpressionModule(io.crate.operation.reference.sys.cluster.SysClusterExpressionModule) Injector(org.elasticsearch.common.inject.Injector) ClusterName(org.elasticsearch.cluster.ClusterName) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) ClusterReferenceResolver(io.crate.metadata.ClusterReferenceResolver) Module(org.elasticsearch.common.inject.Module) SysClusterExpressionModule(io.crate.operation.reference.sys.cluster.SysClusterExpressionModule) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) CrateSettings(io.crate.metadata.settings.CrateSettings) Settings(org.elasticsearch.common.settings.Settings) Before(org.junit.Before)

Example 18 with NoopClusterService

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

the class BlobIndicesServiceTest method testBlobComponentsAreNotCreatedForNonBlobIndex.

@Test
public void testBlobComponentsAreNotCreatedForNonBlobIndex() throws Exception {
    CompletableFuture<IndicesLifecycle.Listener> listenerFuture = new CompletableFuture<>();
    BlobIndicesService blobIndicesService = new BlobIndicesService(Settings.EMPTY, new NoopClusterService(), new IndicesLifecycle() {

        @Override
        public void addListener(Listener listener) {
            listenerFuture.complete(listener);
        }

        @Override
        public void removeListener(Listener listener) {
        }
    });
    IndicesLifecycle.Listener listener = listenerFuture.get(30, TimeUnit.SECONDS);
    IndexService indexService = mock(IndexService.class);
    when(indexService.index()).thenReturn(new Index("dummy"));
    listener.afterIndexCreated(indexService);
    IndexShard indexShard = mock(IndexShard.class);
    when(indexShard.indexService()).thenReturn(indexService);
    listener.afterIndexShardCreated(indexShard);
    assertThat(blobIndicesService.indices.keySet(), Matchers.empty());
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) IndexService(org.elasticsearch.index.IndexService) IndexShard(org.elasticsearch.index.shard.IndexShard) Index(org.elasticsearch.index.Index) IndicesLifecycle(org.elasticsearch.indices.IndicesLifecycle) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 19 with NoopClusterService

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

the class OptimizeTableAnalyzerTest method init.

@Before
public void init() throws Exception {
    TableIdent myBlobsIdent = new TableIdent(BlobSchemaInfo.NAME, "blobs");
    NoopClusterService clusterService = new NoopClusterService();
    TestingBlobTableInfo myBlobsTableInfo = TableDefinitions.createBlobTable(myBlobsIdent, clusterService);
    e = SQLExecutor.builder(clusterService).enableDefaultTables().addBlobTable(myBlobsTableInfo).build();
}
Also used : TableIdent(io.crate.metadata.TableIdent) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Before(org.junit.Before)

Example 20 with NoopClusterService

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

the class UpdateAnalyzerTest method init.

@Before
public void init() {
    SQLExecutor.Builder builder = SQLExecutor.builder(new NoopClusterService()).enableDefaultTables().addDocTable(nestedClusteredByTableInfo).addDocTable(testAliasTableInfo).addDocTable(tiNestedPk);
    TableIdent partedGeneratedColumnTableIdent = new TableIdent(null, "parted_generated_column");
    TestingTableInfo.Builder partedGeneratedColumnTableInfo = new TestingTableInfo.Builder(partedGeneratedColumnTableIdent, new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of())).add("ts", DataTypes.TIMESTAMP, null).addGeneratedColumn("day", DataTypes.TIMESTAMP, "date_trunc('day', ts)", true);
    builder.addDocTable(partedGeneratedColumnTableInfo);
    TableIdent nestedPartedGeneratedColumnTableIdent = new TableIdent(null, "nested_parted_generated_column");
    TestingTableInfo.Builder nestedPartedGeneratedColumnTableInfo = new TestingTableInfo.Builder(nestedPartedGeneratedColumnTableIdent, new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of())).add("user", DataTypes.OBJECT, null).add("user", DataTypes.STRING, Arrays.asList("name")).addGeneratedColumn("name", DataTypes.STRING, "concat(user['name'], 'bar')", true);
    builder.addDocTable(nestedPartedGeneratedColumnTableInfo);
    e = builder.build();
}
Also used : SQLExecutor(io.crate.testing.SQLExecutor) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) ImmutableMap(com.google.common.collect.ImmutableMap) TestingTableInfo(io.crate.metadata.table.TestingTableInfo) Before(org.junit.Before)

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