Search in sources :

Example 16 with TestingBatchConsumer

use of io.crate.testing.TestingBatchConsumer in project crate by crate.

the class TransportExecutorDDLTest method executePlan.

private Bucket executePlan(Plan plan) throws Exception {
    TestingBatchConsumer consumer = new TestingBatchConsumer();
    executor.execute(plan, consumer, Row.EMPTY);
    return consumer.getBucket();
}
Also used : TestingBatchConsumer(io.crate.testing.TestingBatchConsumer)

Example 17 with TestingBatchConsumer

use of io.crate.testing.TestingBatchConsumer in project crate by crate.

the class TransportExecutorDDLTest method testDeletePartitionTaskClosed.

/**
     * this case should not happen as closed indices aren't listed as TableInfo
     * but if it does maybe because of stale cluster state - validate behaviour here
     * <p>
     * cannot prevent this task from deleting closed indices.
     */
@Test
public void testDeletePartitionTaskClosed() throws Exception {
    execute("create table t (id integer primary key, name string) partitioned by (id)");
    ensureYellow();
    execute("insert into t (id, name) values (1, 'Ford')");
    assertThat(response.rowCount(), is(1L));
    ensureYellow();
    String partitionName = new PartitionName("t", ImmutableList.of(new BytesRef("1"))).asIndexName();
    assertTrue(client().admin().indices().prepareClose(partitionName).execute().actionGet().isAcknowledged());
    ESDeletePartition plan = new ESDeletePartition(UUID.randomUUID(), partitionName);
    TestingBatchConsumer consumer = new TestingBatchConsumer();
    executor.execute(plan, consumer, Row.EMPTY);
    Bucket bucket = consumer.getBucket();
    assertThat(bucket, contains(isRow(-1L)));
    execute("select * from information_schema.table_partitions where table_name = 't'");
    assertThat(response.rowCount(), is(0L));
}
Also used : PartitionName(io.crate.metadata.PartitionName) Bucket(io.crate.data.Bucket) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) BytesRef(org.apache.lucene.util.BytesRef) ESDeletePartition(io.crate.planner.node.ddl.ESDeletePartition) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest) Test(org.junit.Test)

Example 18 with TestingBatchConsumer

use of io.crate.testing.TestingBatchConsumer in project crate by crate.

the class KillTaskTest method testKillTaskCallsBroadcastOnTransportKillAllNodeAction.

@SuppressWarnings("unchecked")
@Test
public void testKillTaskCallsBroadcastOnTransportKillAllNodeAction() throws Exception {
    TransportKillAllNodeAction killAllNodeAction = mock(TransportKillAllNodeAction.class);
    KillTask task = new KillTask(killAllNodeAction, UUID.randomUUID());
    task.execute(new TestingBatchConsumer(), Row.EMPTY);
    verify(killAllNodeAction, times(1)).broadcast(any(KillAllRequest.class), any(ActionListener.class));
    verify(killAllNodeAction, times(0)).nodeOperation(any(KillAllRequest.class), any(ActionListener.class));
}
Also used : KillAllRequest(io.crate.executor.transport.kill.KillAllRequest) ActionListener(org.elasticsearch.action.ActionListener) TransportKillAllNodeAction(io.crate.executor.transport.kill.TransportKillAllNodeAction) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 19 with TestingBatchConsumer

use of io.crate.testing.TestingBatchConsumer in project crate by crate.

the class RemoteCollectorTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    UUID jobId = UUID.randomUUID();
    RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 0, "remoteCollect", new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of("remoteNode", ImmutableMap.of("dummyTable", Collections.singletonList(1)))), RowGranularity.DOC, Collections.<Symbol>singletonList(createReference("name", DataTypes.STRING)), Collections.<Projection>emptyList(), WhereClause.MATCH_ALL, DistributionInfo.DEFAULT_BROADCAST);
    transportJobAction = mock(TransportJobAction.class);
    transportKillJobsNodeAction = mock(TransportKillJobsNodeAction.class);
    consumer = new TestingBatchConsumer();
    JobsLogs jobsLogs = new JobsLogs(() -> true);
    JobContextService jobContextService = new JobContextService(Settings.EMPTY, new NoopClusterService(), jobsLogs);
    remoteCollector = new RemoteCollector(jobId, "localNode", "remoteNode", transportJobAction, transportKillJobsNodeAction, jobContextService, mock(RamAccountingContext.class), consumer, collectPhase);
}
Also used : TransportJobAction(io.crate.action.job.TransportJobAction) TransportKillJobsNodeAction(io.crate.executor.transport.kill.TransportKillJobsNodeAction) Routing(io.crate.metadata.Routing) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) JobsLogs(io.crate.operation.collect.stats.JobsLogs) UUID(java.util.UUID) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) JobContextService(io.crate.jobs.JobContextService) Before(org.junit.Before)

Example 20 with TestingBatchConsumer

use of io.crate.testing.TestingBatchConsumer in project crate by crate.

the class FileReadingCollectorTest method testCollectFromS3Uri.

@Test
public void testCollectFromS3Uri() throws Throwable {
    // this test just verifies the s3 schema detection and bucketName / prefix extraction from the uri.
    // real s3 interaction is mocked completely.
    TestingBatchConsumer projector = getObjects("s3://fakebucket/foo");
    projector.getResult();
}
Also used : TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

TestingBatchConsumer (io.crate.testing.TestingBatchConsumer)47 Test (org.junit.Test)41 CrateUnitTest (io.crate.test.integration.CrateUnitTest)32 BytesRef (org.apache.lucene.util.BytesRef)7 CollectionBucket (io.crate.data.CollectionBucket)6 Bucket (io.crate.data.Bucket)4 PageResultListener (io.crate.operation.PageResultListener)4 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)4 Streamer (io.crate.Streamer)3 NestedLoopBatchIterator (io.crate.data.join.NestedLoopBatchIterator)3 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)3 Routing (io.crate.metadata.Routing)3 SharedShardContexts (io.crate.action.job.SharedShardContexts)2 InputColumn (io.crate.analyze.symbol.InputColumn)2 ArrayBucket (io.crate.data.ArrayBucket)2 BatchConsumer (io.crate.data.BatchConsumer)2 CompositeBatchIterator (io.crate.data.CompositeBatchIterator)2 PageDownstreamContext (io.crate.jobs.PageDownstreamContext)2 PartitionName (io.crate.metadata.PartitionName)2 CollectExpression (io.crate.operation.collect.CollectExpression)2