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