use of org.apache.beam.runners.dataflow.options.DataflowPipelineOptions in project beam by apache.
the class DataflowRunnerTest method testTextIOWithRuntimeParameters.
@Test
public void testTextIOWithRuntimeParameters() throws IOException {
DataflowPipelineOptions dataflowOptions = buildPipelineOptions();
RuntimeTestOptions options = dataflowOptions.as(RuntimeTestOptions.class);
Pipeline p = buildDataflowPipeline(dataflowOptions);
p.apply(TextIO.read().from(options.getInput())).apply(TextIO.write().to(options.getOutput()));
}
use of org.apache.beam.runners.dataflow.options.DataflowPipelineOptions in project beam by apache.
the class DataflowRunnerTest method testProjectPrefix.
@Test
public void testProjectPrefix() throws IOException {
DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
options.setRunner(DataflowRunner.class);
options.setProject("google.com:some-project-12345");
options.setGcpTempLocation(VALID_TEMP_BUCKET);
options.setGcsUtil(mockGcsUtil);
options.setGcpCredential(new TestCredential());
DataflowRunner.fromOptions(options);
}
use of org.apache.beam.runners.dataflow.options.DataflowPipelineOptions in project beam by apache.
the class DataflowRunnerTest method testNonExistentStagingLocation.
@Test
public void testNonExistentStagingLocation() throws IOException {
DataflowPipelineOptions options = buildPipelineOptions();
options.setStagingLocation(NON_EXISTENT_BUCKET);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(containsString("Output path does not exist or is not writeable: " + NON_EXISTENT_BUCKET));
DataflowRunner.fromOptions(options);
ArgumentCaptor<Job> jobCaptor = ArgumentCaptor.forClass(Job.class);
Mockito.verify(mockJobs).create(eq(PROJECT_ID), eq(REGION_ID), jobCaptor.capture());
assertValidJob(jobCaptor.getValue());
}
use of org.apache.beam.runners.dataflow.options.DataflowPipelineOptions in project beam by apache.
the class DataflowRunnerTest method testTransformTranslatorMissing.
@Test
public void testTransformTranslatorMissing() throws IOException {
DataflowPipelineOptions options = buildPipelineOptions();
Pipeline p = Pipeline.create(options);
p.apply(Create.of(Arrays.asList(1, 2, 3))).apply(new TestTransform());
thrown.expect(IllegalStateException.class);
thrown.expectMessage(Matchers.containsString("no translator registered"));
DataflowPipelineTranslator.fromOptions(options).translate(p, DataflowRunner.fromOptions(options), Collections.<DataflowPackage>emptyList());
ArgumentCaptor<Job> jobCaptor = ArgumentCaptor.forClass(Job.class);
Mockito.verify(mockJobs).create(eq(PROJECT_ID), eq(REGION_ID), jobCaptor.capture());
assertValidJob(jobCaptor.getValue());
}
use of org.apache.beam.runners.dataflow.options.DataflowPipelineOptions in project beam by apache.
the class DataflowRunnerTest method testTransformTranslator.
@Test
public void testTransformTranslator() throws IOException {
// Test that we can provide a custom translation
DataflowPipelineOptions options = buildPipelineOptions();
Pipeline p = Pipeline.create(options);
TestTransform transform = new TestTransform();
p.apply(Create.of(Arrays.asList(1, 2, 3)).withCoder(BigEndianIntegerCoder.of())).apply(transform);
DataflowPipelineTranslator translator = DataflowRunner.fromOptions(options).getTranslator();
DataflowPipelineTranslator.registerTransformTranslator(TestTransform.class, new TransformTranslator<TestTransform>() {
@SuppressWarnings("unchecked")
@Override
public void translate(TestTransform transform, TranslationContext context) {
transform.translated = true;
// Note: This is about the minimum needed to fake out a
// translation. This obviously isn't a real translation.
StepTranslationContext stepContext = context.addStep(transform, "TestTranslate");
stepContext.addOutput(context.getOutput(transform));
}
});
translator.translate(p, DataflowRunner.fromOptions(options), Collections.<DataflowPackage>emptyList());
assertTrue(transform.translated);
}
Aggregations