You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ch...@apache.org on 2019/03/05 18:14:05 UTC

[beam] branch master updated: Add BQ Storage API case to BigQueryTornadoesIT.

This is an automated email from the ASF dual-hosted git repository.

chamikara pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 24d1c9f  Add BQ Storage API case to BigQueryTornadoesIT.
     new dcfafae  Merge pull request #7963 from kmjung/master_bq_tornadoes
24d1c9f is described below

commit 24d1c9fce962c7e0ee304d5489e041a58b37d967
Author: Kenneth Jung <km...@google.com>
AuthorDate: Wed Feb 27 11:33:58 2019 -0800

    Add BQ Storage API case to BigQueryTornadoesIT.
    
    This change adds integration test coverage to the BigQueryTornadoes
    sample to cover both the export and read API-based cases.
---
 .../examples/cookbook/BigQueryTornadoesIT.java     | 31 +++++++++++++++++-----
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/examples/java/src/test/java/org/apache/beam/examples/cookbook/BigQueryTornadoesIT.java b/examples/java/src/test/java/org/apache/beam/examples/cookbook/BigQueryTornadoesIT.java
index b64d2ff..c53f49b 100644
--- a/examples/java/src/test/java/org/apache/beam/examples/cookbook/BigQueryTornadoesIT.java
+++ b/examples/java/src/test/java/org/apache/beam/examples/cookbook/BigQueryTornadoesIT.java
@@ -17,6 +17,7 @@
  */
 package org.apache.beam.examples.cookbook;
 
+import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.Method;
 import org.apache.beam.sdk.io.gcp.bigquery.BigQueryOptions;
 import org.apache.beam.sdk.io.gcp.testing.BigqueryMatcher;
 import org.apache.beam.sdk.options.PipelineOptionsFactory;
@@ -60,19 +61,37 @@ public class BigQueryTornadoesIT {
     PipelineOptionsFactory.register(BigQueryTornadoesITOptions.class);
   }
 
+  private void runE2EBigQueryTornadoesTest(BigQueryTornadoesITOptions options) throws Exception {
+    String query = String.format("SELECT month, tornado_count FROM [%s]", options.getOutput());
+    options.setOnSuccessMatcher(
+        new BigqueryMatcher(
+            options.getAppName(), options.getProject(), query, DEFAULT_OUTPUT_CHECKSUM));
+
+    BigQueryTornadoes.runBigQueryTornadoes(options);
+  }
+
   @Test
-  public void testE2EBigQueryTornadoes() throws Exception {
+  public void testE2EBigQueryTornadoesWithExport() throws Exception {
     BigQueryTornadoesITOptions options =
         TestPipeline.testingPipelineOptions().as(BigQueryTornadoesITOptions.class);
+    options.setReadMethod(Method.EXPORT);
     options.setOutput(
         String.format(
             "%s.%s", "BigQueryTornadoesIT", "monthly_tornadoes_" + System.currentTimeMillis()));
 
-    String query = String.format("SELECT month, tornado_count FROM [%s]", options.getOutput());
-    options.setOnSuccessMatcher(
-        new BigqueryMatcher(
-            options.getAppName(), options.getProject(), query, DEFAULT_OUTPUT_CHECKSUM));
+    runE2EBigQueryTornadoesTest(options);
+  }
 
-    BigQueryTornadoes.runBigQueryTornadoes(options);
+  @Test
+  public void testE2eBigQueryTornadoesWithStorageApi() throws Exception {
+    BigQueryTornadoesITOptions options =
+        TestPipeline.testingPipelineOptions().as(BigQueryTornadoesITOptions.class);
+    options.setReadMethod(Method.DIRECT_READ);
+    options.setOutput(
+        String.format(
+            "%s.%s",
+            "BigQueryTornadoesIT", "monthly_tornadoes_storage_" + System.currentTimeMillis()));
+
+    runE2EBigQueryTornadoesTest(options);
   }
 }