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());
}
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();
}
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"));
}
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();
}
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());
}
Aggregations