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"));
}
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"));
}
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"));
}
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);
}
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);
}
Aggregations