[
https://issues.apache.org/jira/browse/BEAM-5269?focusedWorklogId=140987&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-140987
]
ASF GitHub Bot logged work on BEAM-5269:
----------------------------------------
Author: ASF GitHub Bot
Created on: 04/Sep/18 17:50
Start Date: 04/Sep/18 17:50
Worklog Time Spent: 10m
Work Description: pabloem closed pull request #6320: [BEAM-5269]
Integration tests for BigQueryIORead
URL: https://github.com/apache/beam/pull/6320
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOReadIT.java
b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOReadIT.java
new file mode 100644
index 00000000000..61141efd8a1
--- /dev/null
+++
b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOReadIT.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.beam.sdk.io.gcp.bigquery;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.extensions.gcp.options.GcpOptions;
+import org.apache.beam.sdk.options.Description;
+import org.apache.beam.sdk.options.PipelineOptionsFactory;
+import org.apache.beam.sdk.options.Validation;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.testing.TestPipelineOptions;
+import org.apache.beam.sdk.transforms.Count;
+import org.apache.beam.sdk.values.PCollection;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Integration test for BigQueryIORead. It reads from a specified table and
then asserts that the
+ * number of records read equals the given expected number of records.
+ */
+@RunWith(JUnit4.class)
+public class BigQueryIOReadIT {
+
+ private BigQueryIOReadOptions options;
+ private String project;
+ private static final String datasetId = "big_query_import_export";
+ private static final String tablePrefix = "export_";
+ private static final Map<String, Integer> numOfRecords =
ImmutableMap.of("empty", 0, "1K", 1000);
+
+ /** Customized PipelineOption for BigQueryIORead Pipeline. */
+ public interface BigQueryIOReadOptions extends TestPipelineOptions {
+ @Description("The table to be read")
+ @Validation.Required
+ String getInputTable();
+
+ void setInputTable(String filename);
+
+ @Description("The expected number of records")
+ @Validation.Required
+ long getNumRecords();
+
+ void setNumRecords(long numRecords);
+ }
+
+ private void setupTestEnvironment(String recordSize) {
+ PipelineOptionsFactory.register(BigQueryIOReadOptions.class);
+ options =
TestPipeline.testingPipelineOptions().as(BigQueryIOReadOptions.class);
+ options.setNumRecords(numOfRecords.get(recordSize));
+ options.setTempLocation(options.getTempRoot() + "/temp-it/");
+ project =
TestPipeline.testingPipelineOptions().as(GcpOptions.class).getProject();
+ options.setInputTable(project + ":" + datasetId + "." + tablePrefix +
recordSize);
+ }
+
+ private void runBigQueryIOReadPipeline() {
+ Pipeline p = Pipeline.create(options);
+ PCollection<Long> count =
+ p.apply("Read", BigQueryIO.read().from(options.getInputTable()))
+ .apply("Count", Count.globally());
+ PAssert.thatSingleton(count).isEqualTo(options.getNumRecords());
+
+ p.run().waitUntilFinish();
+ }
+
+ @Test
+ public void testBigQueryReadEmpty() throws Exception {
+ setupTestEnvironment("empty");
+ runBigQueryIOReadPipeline();
+ }
+
+ @Test
+ public void testBigQueryRead1K() throws Exception {
+ setupTestEnvironment("1K");
+ runBigQueryIOReadPipeline();
+ }
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 140987)
Time Spent: 1h 20m (was: 1h 10m)
> Create integration tests for BigQueryIORead pipeline
> ----------------------------------------------------
>
> Key: BEAM-5269
> URL: https://issues.apache.org/jira/browse/BEAM-5269
> Project: Beam
> Issue Type: Bug
> Components: testing
> Reporter: yifan zou
> Assignee: yifan zou
> Priority: Major
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)