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