Search in sources :

Example 26 with PipelineOptions

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);
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) CrashingRunner(org.apache.beam.sdk.testing.CrashingRunner) Test(org.junit.Test)

Example 27 with PipelineOptions

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));
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) Pipeline(org.apache.beam.sdk.Pipeline) Test(org.junit.Test)

Example 28 with PipelineOptions

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();
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) Pipeline(org.apache.beam.sdk.Pipeline) Test(org.junit.Test)

Example 29 with PipelineOptions

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));
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) Test(org.junit.Test)

Example 30 with PipelineOptions

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);
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) Test(org.junit.Test)

Aggregations

PipelineOptions (org.apache.beam.sdk.options.PipelineOptions)92 Test (org.junit.Test)79 File (java.io.File)26 ArrayList (java.util.ArrayList)16 Pipeline (org.apache.beam.sdk.Pipeline)10 Metadata (org.apache.beam.sdk.io.fs.MatchResult.Metadata)9 Path (java.nio.file.Path)6 BigQueryHelpers.toJsonString (org.apache.beam.sdk.io.gcp.bigquery.BigQueryHelpers.toJsonString)6 SerializedPipelineOptions (org.apache.beam.runners.flink.translation.utils.SerializedPipelineOptions)5 KV (org.apache.beam.sdk.values.KV)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 Table (com.google.api.services.bigquery.model.Table)4 TableReference (com.google.api.services.bigquery.model.TableReference)4 TableRow (com.google.api.services.bigquery.model.TableRow)4 HashBasedTable (com.google.common.collect.HashBasedTable)4 BoundedToUnboundedSourceAdapter (org.apache.beam.runners.core.construction.UnboundedReadFromBoundedSource.BoundedToUnboundedSourceAdapter)4 BigQueryHelpers.createTempTableReference (org.apache.beam.sdk.io.gcp.bigquery.BigQueryHelpers.createTempTableReference)4 TestPipeline (org.apache.beam.sdk.testing.TestPipeline)4 TableFieldSchema (com.google.api.services.bigquery.model.TableFieldSchema)3 TableSchema (com.google.api.services.bigquery.model.TableSchema)3