Search in sources :

Example 21 with TestCredential

use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.

the class GoogleApiDebugOptionsTest method testMatchingAgainstRequestType.

@Test
public void testMatchingAgainstRequestType() throws Exception {
    GcsOptions options = PipelineOptionsFactory.as(GcsOptions.class);
    options.setGcpCredential(new TestCredential());
    options.setGoogleApiTrace(new GoogleApiTracer().addTraceFor(Transport.newStorageClient(options).build().objects().get("aProjectId", "aObjectId"), "TraceDestination"));
    Storage.Objects.Get getRequest = Transport.newStorageClient(options).build().objects().get("testBucketId", "testObjectId");
    assertEquals("TraceDestination", getRequest.get("$trace"));
    Storage.Objects.List listRequest = Transport.newStorageClient(options).build().objects().list("testProjectId");
    assertNull(listRequest.get("$trace"));
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) GoogleApiTracer(org.apache.beam.sdk.extensions.gcp.options.GoogleApiDebugOptions.GoogleApiTracer) Test(org.junit.Test)

Example 22 with TestCredential

use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.

the class MonitoringUtilTest method testDontOverrideEndpointWithDefaultApi.

@Test
public void testDontOverrideEndpointWithDefaultApi() {
    DataflowPipelineOptions options = PipelineOptionsFactory.create().as(DataflowPipelineOptions.class);
    options.setProject(PROJECT_ID);
    options.setGcpCredential(new TestCredential());
    String cancelCommand = MonitoringUtil.getGcloudCancelCommand(options, JOB_ID);
    assertEquals("gcloud beta dataflow jobs --project=someProject cancel 1234", cancelCommand);
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) DataflowPipelineOptions(org.apache.beam.runners.dataflow.options.DataflowPipelineOptions) Test(org.junit.Test)

Example 23 with TestCredential

use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential 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);
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) DataflowPipelineOptions(org.apache.beam.runners.dataflow.options.DataflowPipelineOptions) Test(org.junit.Test)

Example 24 with TestCredential

use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.

the class TestDataflowRunnerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    options = PipelineOptionsFactory.as(TestDataflowPipelineOptions.class);
    options.setAppName("TestAppName");
    options.setProject("test-project");
    options.setTempLocation("gs://test/temp/location");
    options.setTempRoot("gs://test");
    options.setGcpCredential(new TestCredential());
    options.setRunner(TestDataflowRunner.class);
    options.setPathValidatorClass(NoopPathValidator.class);
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) Before(org.junit.Before)

Example 25 with TestCredential

use of org.apache.beam.sdk.extensions.gcp.auth.TestCredential in project beam by apache.

the class DataflowRunnerTest method testTemplateRunnerLoggedErrorForFile.

/**
   * Tests that the {@link DataflowRunner} with {@code --templateLocation} throws the appropriate
   * exception when an output file is not writable.
   */
@Test
public void testTemplateRunnerLoggedErrorForFile() throws Exception {
    DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
    options.setJobName("TestJobName");
    options.setRunner(DataflowRunner.class);
    options.setTemplateLocation("//bad/path");
    options.setProject("test-project");
    options.setTempLocation(tmpFolder.getRoot().getPath());
    options.setGcpCredential(new TestCredential());
    options.setPathValidatorClass(NoopPathValidator.class);
    Pipeline p = Pipeline.create(options);
    thrown.expectMessage("Cannot create output file at");
    thrown.expect(RuntimeException.class);
    p.run();
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) DataflowPipelineOptions(org.apache.beam.runners.dataflow.options.DataflowPipelineOptions) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) Pipeline(org.apache.beam.sdk.Pipeline) Test(org.junit.Test)

Aggregations

TestCredential (org.apache.beam.sdk.extensions.gcp.auth.TestCredential)28 Test (org.junit.Test)19 DataflowPipelineOptions (org.apache.beam.runners.dataflow.options.DataflowPipelineOptions)14 Before (org.junit.Before)5 GcsPath (org.apache.beam.sdk.util.gcsfs.GcsPath)4 Pipeline (org.apache.beam.sdk.Pipeline)3 TestPipeline (org.apache.beam.sdk.testing.TestPipeline)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 BigtableOptions (com.google.cloud.bigtable.config.BigtableOptions)2 ImmutableList (com.google.common.collect.ImmutableList)2 File (java.io.File)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 GcpOptions (org.apache.beam.sdk.extensions.gcp.options.GcpOptions)2 GcsOptions (org.apache.beam.sdk.extensions.gcp.options.GcsOptions)2 GoogleApiTracer (org.apache.beam.sdk.extensions.gcp.options.GoogleApiDebugOptions.GoogleApiTracer)2 GcsUtil (org.apache.beam.sdk.util.GcsUtil)2 TupleTagList (org.apache.beam.sdk.values.TupleTagList)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Matchers.anyString (org.mockito.Matchers.anyString)2