Search in sources :

Example 41 with TestingBatchConsumer

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

the class FileReadingCollectorTest method testCollectFromDirectory.

@Test
public void testCollectFromDirectory() throws Throwable {
    TestingBatchConsumer projector = getObjects(Paths.get(tmpFile.getParentFile().toURI()).toUri().toString() + "*");
    assertCorrectResult(projector.getBucket());
}
Also used : TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 42 with TestingBatchConsumer

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

the class FileReadingCollectorTest method testCollectWithOneSocketTimeout.

@Test
public void testCollectWithOneSocketTimeout() throws Throwable {
    S3ObjectInputStream inputStream = mock(S3ObjectInputStream.class);
    when(inputStream.read(new byte[anyInt()], anyInt(), anyByte())).thenAnswer(// first line: foo
    new WriteBufferAnswer(new byte[] { 102, 111, 111, 10 })).thenThrow(// exception causes retry
    new SocketTimeoutException()).thenAnswer(// first line again, because of retry
    new WriteBufferAnswer(new byte[] { 102, 111, 111, 10 })).thenAnswer(// second line: bar
    new WriteBufferAnswer(new byte[] { 98, 97, 114, 10 })).thenReturn(-1);
    TestingBatchConsumer consumer = getObjects(Collections.singletonList("s3://fakebucket/foo"), null, inputStream);
    Bucket rows = consumer.getBucket();
    assertThat(rows.size(), is(2));
    assertThat(TestingHelpers.printedTable(rows), is("foo\nbar\n"));
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) S3ObjectInputStream(com.amazonaws.services.s3.model.S3ObjectInputStream) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 43 with TestingBatchConsumer

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

the class FileReadingCollectorTest method testCollectWithEmptyLine.

@Test
public void testCollectWithEmptyLine() throws Throwable {
    TestingBatchConsumer consumer = getObjects(Paths.get(tmpFileEmptyLine.toURI()).toUri().toString());
    assertCorrectResult(consumer.getBucket());
}
Also used : TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 44 with TestingBatchConsumer

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

the class JobCollectContextTest method setUp.

@Before
public void setUp() throws Exception {
    localNodeId = "dummyLocalNodeId";
    collectPhase = Mockito.mock(RoutedCollectPhase.class);
    Routing routing = Mockito.mock(Routing.class);
    when(routing.containsShards(localNodeId)).thenReturn(true);
    when(collectPhase.routing()).thenReturn(routing);
    when(collectPhase.maxRowGranularity()).thenReturn(RowGranularity.DOC);
    jobCollectContext = new JobCollectContext(collectPhase, mock(MapSideDataCollectOperation.class), localNodeId, ramAccountingContext, new TestingBatchConsumer(), mock(SharedShardContexts.class));
}
Also used : Routing(io.crate.metadata.Routing) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) Before(org.junit.Before)

Example 45 with TestingBatchConsumer

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

the class FileReadingCollectorTest method testCollectFromUriWithGlob.

@Test
public void testCollectFromUriWithGlob() throws Throwable {
    TestingBatchConsumer projector = getObjects(Paths.get(tmpFile.getParentFile().toURI()).toUri().toString() + "file*.json");
    assertCorrectResult(projector.getBucket());
}
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