Search in sources :

Example 26 with TestingRowConsumer

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

the class CountTaskTest method testKillOperationFuture.

@Test
public void testKillOperationFuture() throws Exception {
    CompletableFuture<Long> future = mock(CompletableFuture.class);
    CountOperation countOperation = new FakeCountOperation(future);
    CountTask countTask = new CountTask(countPhaseWithId(1), txnCtx, countOperation, new TestingRowConsumer(), null);
    countTask.start();
    countTask.kill(JobKilledException.of("dummy"));
    verify(future, times(1)).cancel(true);
    assertTrue(countTask.isClosed());
}
Also used : CountOperation(io.crate.execution.engine.collect.count.CountOperation) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Example 27 with TestingRowConsumer

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

the class S3FileReadingCollectorTest 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.
    TestingRowConsumer projector = getObjects("s3://fakebucket/foo");
    projector.getResult();
}
Also used : TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Example 28 with TestingRowConsumer

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

the class S3FileReadingCollectorTest method testCollectWithOneSocketTimeout.

@Test
public void testCollectWithOneSocketTimeout() throws Throwable {
    S3ObjectInputStream inputStream = mock(S3ObjectInputStream.class);
    when(inputStream.read(any(byte[].class), anyInt(), anyInt())).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);
    TestingRowConsumer consumer = getObjects(Collections.singletonList("s3://fakebucket/foo"), null, inputStream, false);
    Bucket rows = consumer.getBucket();
    assertThat(rows.size(), is(2));
    assertThat(TestingHelpers.printedTable(rows), is("foo\nbar\n"));
}
Also used : SocketTimeoutException(java.net.SocketTimeoutException) Bucket(io.crate.data.Bucket) S3ObjectInputStream(com.amazonaws.services.s3.model.S3ObjectInputStream) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Example 29 with TestingRowConsumer

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

the class UpdateAnalyzerTest method execute.

private List<Object[]> execute(Plan plan, Row params) throws Exception {
    TestingRowConsumer consumer = new TestingRowConsumer();
    plan.execute(mock(DependencyCarrier.class), e.getPlannerContext(clusterService.state()), consumer, params, SubQueryResults.EMPTY);
    return consumer.getResult();
}
Also used : DependencyCarrier(io.crate.planner.DependencyCarrier) TestingRowConsumer(io.crate.testing.TestingRowConsumer)

Example 30 with TestingRowConsumer

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

the class NestedLoopBatchIteratorsTest method testAntiJoinLeftEmpty.

@Test
public void testAntiJoinLeftEmpty() throws Exception {
    BatchIterator<Row> iterator = new AntiJoinNLBatchIterator<>(InMemoryBatchIterator.empty(SENTINEL), TestingBatchIterators.range(0, 5), new CombinedRow(1, 1), getCol0EqCol1JoinCondition());
    TestingRowConsumer consumer = new TestingRowConsumer();
    consumer.accept(iterator, null);
    assertThat(consumer.getResult(), Matchers.empty());
}
Also used : Row(io.crate.data.Row) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test)

Aggregations

TestingRowConsumer (io.crate.testing.TestingRowConsumer)64 Test (org.junit.Test)55 Row (io.crate.data.Row)24 CollectionBucket (io.crate.data.CollectionBucket)11 Bucket (io.crate.data.Bucket)10 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)10 InputColumn (io.crate.expression.symbol.InputColumn)6 BatchSimulatingIterator (io.crate.testing.BatchSimulatingIterator)6 ArrayBucket (io.crate.data.ArrayBucket)5 TestingHelpers.isRow (io.crate.testing.TestingHelpers.isRow)5 Streamer (io.crate.Streamer)4 Projector (io.crate.data.Projector)4 GroupingProjector (io.crate.execution.engine.aggregation.GroupingProjector)4 SortingProjector (io.crate.execution.engine.sort.SortingProjector)4 SortingTopNProjector (io.crate.execution.engine.sort.SortingTopNProjector)4 DistResultRXTask (io.crate.execution.jobs.DistResultRXTask)4 ArrayList (java.util.ArrayList)4 RowAccounting (io.crate.breaker.RowAccounting)3 CombinedRow (io.crate.data.join.CombinedRow)3 CompletionException (java.util.concurrent.CompletionException)3