use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.
the class PipelineRunnerTest method testInstantiation.
@Test
public void testInstantiation() {
PipelineOptions options = PipelineOptionsFactory.create();
options.setRunner(CrashingRunner.class);
PipelineRunner<?> runner = PipelineRunner.fromOptions(options);
assertTrue(runner instanceof CrashingRunner);
}
use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.
the class CrashingRunnerTest method applySucceeds.
@Test
public void applySucceeds() {
PipelineOptions opts = PipelineOptionsFactory.create();
opts.setRunner(CrashingRunner.class);
Pipeline p = Pipeline.create(opts);
p.apply(Create.of(1, 2, 3));
}
use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.
the class CrashingRunnerTest method runThrows.
@Test
public void runThrows() {
PipelineOptions opts = PipelineOptionsFactory.create();
opts.setRunner(CrashingRunner.class);
Pipeline p = Pipeline.create(opts);
p.apply(Create.of(1, 2, 3));
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Cannot call #run");
thrown.expectMessage(TestPipeline.PROPERTY_BEAM_TEST_PIPELINE_OPTIONS);
p.run();
}
use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.
the class SourceTestUtilsTest method testToUnsplittableSource.
@Test
public void testToUnsplittableSource() throws Exception {
PipelineOptions options = PipelineOptionsFactory.create();
BoundedSource<Long> baseSource = CountingSource.upTo(100);
BoundedSource<Long> unsplittableSource = SourceTestUtils.toUnsplittableSource(baseSource);
List<?> splits = unsplittableSource.split(1, options);
assertEquals(splits.size(), 1);
assertEquals(splits.get(0), unsplittableSource);
BoundedReader<Long> unsplittableReader = unsplittableSource.createReader(options);
assertEquals(0, unsplittableReader.getFractionConsumed(), 1e-15);
Set<Long> expected = Sets.newHashSet(SourceTestUtils.readFromSource(baseSource, options));
Set<Long> actual = Sets.newHashSet();
actual.addAll(SourceTestUtils.readNItemsFromUnstartedReader(unsplittableReader, 40));
assertNull(unsplittableReader.splitAtFraction(0.5));
actual.addAll(SourceTestUtils.readRemainingFromReader(unsplittableReader, true));
assertEquals(1, unsplittableReader.getFractionConsumed(), 1e-15);
assertEquals(100, actual.size());
assertEquals(Sets.newHashSet(expected), Sets.newHashSet(actual));
}
use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.
the class CreateTest method testSourceSplitVoid.
@Test
public void testSourceSplitVoid() throws Exception {
CreateSource<Void> source = CreateSource.fromIterable(Lists.<Void>newArrayList(null, null, null, null, null), VoidCoder.of());
PipelineOptions options = PipelineOptionsFactory.create();
List<? extends BoundedSource<Void>> splitSources = source.split(3, options);
SourceTestUtils.assertSourcesEqualReferenceSource(source, splitSources, options);
}
Aggregations