Search in sources :

Example 16 with TestCredential

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

the class GoogleApiDebugOptionsTest method testMatchingAllCalls.

@Test
public void testMatchingAllCalls() throws Exception {
    String[] args = new String[] { STORAGE_TRACE };
    GcsOptions options = PipelineOptionsFactory.fromArgs(args).as(GcsOptions.class);
    options.setGcpCredential(new TestCredential());
    assertNotNull(options.getGoogleApiTrace());
    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");
    assertEquals("TraceDestination", listRequest.get("$trace"));
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) Test(org.junit.Test)

Example 17 with TestCredential

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

the class GoogleApiDebugOptionsTest method testWhenTracingDoesNotMatch.

@Test
public void testWhenTracingDoesNotMatch() throws Exception {
    String[] args = new String[] { STORAGE_GET_TRACE };
    GcsOptions options = PipelineOptionsFactory.fromArgs(args).as(GcsOptions.class);
    options.setGcpCredential(new TestCredential());
    assertNotNull(options.getGoogleApiTrace());
    Storage.Objects.List request = Transport.newStorageClient(options).build().objects().list("testProjectId");
    assertNull(request.get("$trace"));
}
Also used : TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) Test(org.junit.Test)

Example 18 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 19 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 20 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)

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