Search in sources :

Example 96 with PipelineOptions

use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.

the class ExperimentContextTest method testUnsetExperimentsInPipelineOptions.

@Test
public void testUnsetExperimentsInPipelineOptions() {
    PipelineOptions options = PipelineOptionsFactory.create();
    ExperimentContext ec = ExperimentContext.parseFrom(options);
    assertFalse(ec.isEnabled(Experiment.IntertransformIO));
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) Test(org.junit.Test)

Example 97 with PipelineOptions

use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.

the class ReaderFactoryTest method testCreateReader.

@Test
public void testCreateReader() throws Exception {
    CloudObject spec = CloudObject.forClass(TestReaderFactory.class);
    Source cloudSource = new Source();
    cloudSource.setSpec(spec);
    cloudSource.setCodec(CloudObjects.asCloudObject(BigEndianIntegerCoder.of(), /*sdkComponents=*/
    null));
    PipelineOptions options = PipelineOptionsFactory.create();
    ReaderRegistry registry = ReaderRegistry.defaultRegistry().register(TestReaderFactory.class.getName(), new TestReaderFactory());
    NativeReader<?> reader = registry.create(cloudSource, PipelineOptionsFactory.create(), BatchModeExecutionContext.forTesting(options, "testStage"), null);
    assertThat(reader, new IsInstanceOf(TestReader.class));
}
Also used : CloudObject(org.apache.beam.runners.dataflow.util.CloudObject) PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) IsInstanceOf(org.hamcrest.core.IsInstanceOf) Source(com.google.api.services.dataflow.model.Source) Test(org.junit.Test)

Example 98 with PipelineOptions

use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.

the class ShuffleSinkFactoryTest method runTestCreateShuffleSinkHelper.

private ShuffleSink runTestCreateShuffleSinkHelper(byte[] shuffleWriterConfig, String shuffleKind, Coder<?> deserializedCoder, FullWindowedValueCoder<?> coder) throws Exception {
    CloudObject spec = CloudObject.forClassName("ShuffleSink");
    addString(spec, "shuffle_writer_config", encodeBase64String(shuffleWriterConfig));
    addString(spec, "shuffle_kind", shuffleKind);
    PipelineOptions options = PipelineOptionsFactory.create();
    ShuffleSinkFactory factory = new ShuffleSinkFactory();
    Sink<?> sink = factory.create(spec, deserializedCoder, options, BatchModeExecutionContext.forTesting(options, "testStage"), TestOperationContext.create());
    assertThat(sink, new IsInstanceOf(ShuffleSink.class));
    ShuffleSink shuffleSink = (ShuffleSink) sink;
    Assert.assertArrayEquals(shuffleWriterConfig, shuffleSink.shuffleWriterConfig);
    Assert.assertEquals(coder, shuffleSink.windowedElemCoder);
    return shuffleSink;
}
Also used : CloudObject(org.apache.beam.runners.dataflow.util.CloudObject) PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) IsInstanceOf(org.hamcrest.core.IsInstanceOf)

Example 99 with PipelineOptions

use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.

the class ForwardingPTransformTest method validateDelegates.

@Test
public void validateDelegates() {
    @SuppressWarnings("unchecked") PipelineOptions options = mock(PipelineOptions.class);
    doThrow(RuntimeException.class).when(delegate).validate(options);
    thrown.expect(RuntimeException.class);
    forwarding.validate(options);
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) Test(org.junit.Test)

Example 100 with PipelineOptions

use of org.apache.beam.sdk.options.PipelineOptions in project beam by apache.

the class SerializablePipelineOptionsTest method equalityTest.

@Test
public void equalityTest() {
    PipelineOptions options = PipelineOptionsFactory.create();
    SerializablePipelineOptions serializablePipelineOptions = new SerializablePipelineOptions(options);
    String json = serializablePipelineOptions.toString();
    SerializablePipelineOptions serializablePipelineOptions2 = new SerializablePipelineOptions(json);
    assertEquals("SerializablePipelineOptions created from options and from json differ", serializablePipelineOptions, serializablePipelineOptions2);
}
Also used : PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) Test(org.junit.Test)

Aggregations

PipelineOptions (org.apache.beam.sdk.options.PipelineOptions)282 Test (org.junit.Test)173 Pipeline (org.apache.beam.sdk.Pipeline)80 File (java.io.File)36 ArrayList (java.util.ArrayList)29 KV (org.apache.beam.sdk.values.KV)27 TestPipeline (org.apache.beam.sdk.testing.TestPipeline)21 List (java.util.List)18 DataflowPipelineOptions (org.apache.beam.runners.dataflow.options.DataflowPipelineOptions)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 IOException (java.io.IOException)12 ExperimentalOptions (org.apache.beam.sdk.options.ExperimentalOptions)12 Map (java.util.Map)11 PCollection (org.apache.beam.sdk.values.PCollection)11 Instant (org.joda.time.Instant)11 TableRow (com.google.api.services.bigquery.model.TableRow)10 CloudObject (org.apache.beam.runners.dataflow.util.CloudObject)10 ByteString (com.google.protobuf.ByteString)8 BoundedToUnboundedSourceAdapter (org.apache.beam.runners.core.construction.UnboundedReadFromBoundedSource.BoundedToUnboundedSourceAdapter)8 DataflowPipelineDebugOptions (org.apache.beam.runners.dataflow.options.DataflowPipelineDebugOptions)8