use of io.crate.testing.TestingRowConsumer in project crate by crate.
the class HandlerSideLevelCollectTest method collect.
private Bucket collect(RoutedCollectPhase collectPhase) throws Exception {
TestingRowConsumer consumer = new TestingRowConsumer();
CollectTask collectTask = mock(CollectTask.class);
when(collectTask.txnCtx()).thenReturn(txnCtx);
BatchIterator<Row> bi = operation.createIterator(txnCtx, collectPhase, consumer.requiresScroll(), collectTask).get(5, TimeUnit.SECONDS);
consumer.accept(bi, null);
return new CollectionBucket(consumer.getResult());
}
use of io.crate.testing.TestingRowConsumer in project crate by crate.
the class DistributingConsumerTest method testSendUsingDistributingConsumerAndReceiveWithDistResultRXTask.
@Test
public void testSendUsingDistributingConsumerAndReceiveWithDistResultRXTask() throws Exception {
try {
Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
TestingRowConsumer collectingConsumer = new TestingRowConsumer();
DistResultRXTask distResultRXTask = createPageDownstreamContext(streamers, collectingConsumer);
TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, distResultRXTask);
DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
BatchSimulatingIterator<Row> batchSimulatingIterator = new BatchSimulatingIterator<>(TestingBatchIterators.range(0, 5), 2, 3, executorService);
distributingConsumer.accept(batchSimulatingIterator, null);
List<Object[]> result = collectingConsumer.getResult();
assertThat(TestingHelpers.printedTable(new CollectionBucket(result)), is("0\n" + "1\n" + "2\n" + "3\n" + "4\n"));
// pageSize=2 and 5 rows causes 3x pushResult
verify(distributedResultAction, times(3)).pushResult(anyString(), any(), any());
} finally {
executorService.shutdown();
executorService.awaitTermination(10, TimeUnit.SECONDS);
}
}
use of io.crate.testing.TestingRowConsumer in project crate by crate.
the class DistributingConsumerTest method testFailureOnAllLoadedIsForwarded.
@Test
public void testFailureOnAllLoadedIsForwarded() throws Exception {
Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
TestingRowConsumer collectingConsumer = new TestingRowConsumer();
DistResultRXTask distResultRXTask = createPageDownstreamContext(streamers, collectingConsumer);
TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, distResultRXTask);
DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
distributingConsumer.accept(FailingBatchIterator.failOnAllLoaded(), null);
expectedException.expect(InterruptedException.class);
collectingConsumer.getResult();
}
use of io.crate.testing.TestingRowConsumer in project crate by crate.
the class OrderedLuceneBatchIteratorFactoryTest method consumeIteratorAndVerifyResultIsException.
private void consumeIteratorAndVerifyResultIsException(BatchIterator<Row> rowBatchIterator, Exception exception) throws Exception {
TestingRowConsumer consumer = new TestingRowConsumer();
consumer.accept(rowBatchIterator, null);
expectedException.expect(exception.getClass());
expectedException.expectMessage(exception.getMessage());
consumer.getResult();
}
use of io.crate.testing.TestingRowConsumer in project crate by crate.
the class FileReadingCollectorTest method getObjects.
private TestingRowConsumer getObjects(Collection<String> fileUris, String compression, boolean collectSourceUriFailure) throws Throwable {
TestingRowConsumer consumer = new TestingRowConsumer();
getObjects(fileUris, compression, consumer, collectSourceUriFailure);
return consumer;
}
Aggregations