use of org.apache.beam.runners.apex.translation.utils.CollectionSource in project beam by apache.
the class ReadUnboundTranslatorTest method test.
@Test
public void test() throws Exception {
ApexPipelineOptions options = PipelineOptionsFactory.create().as(ApexPipelineOptions.class);
EmbeddedCollector.RESULTS.clear();
options.setApplicationName("ReadUnbound");
options.setRunner(ApexRunner.class);
Pipeline p = Pipeline.create(options);
List<String> collection = Lists.newArrayList("1", "2", "3", "4", "5");
CollectionSource<String> source = new CollectionSource<>(collection, StringUtf8Coder.of());
p.apply(Read.from(source)).apply(ParDo.of(new EmbeddedCollector()));
ApexRunnerResult result = (ApexRunnerResult) p.run();
DAG dag = result.getApexDAG();
DAG.OperatorMeta om = dag.getOperatorMeta("Read(CollectionSource)");
Assert.assertNotNull(om);
Assert.assertEquals(om.getOperator().getClass(), ApexReadUnboundedInputOperator.class);
long timeout = System.currentTimeMillis() + 30000;
while (System.currentTimeMillis() < timeout) {
if (EmbeddedCollector.RESULTS.containsAll(collection)) {
break;
}
LOG.info("Waiting for expected results.");
Thread.sleep(1000);
}
Assert.assertEquals(Sets.newHashSet(collection), EmbeddedCollector.RESULTS);
}
Aggregations