yanghua commented on a change in pull request #1774:
URL: https://github.com/apache/hudi/pull/1774#discussion_r454987028



##########
File path: 
hudi-integ-test/src/test/java/org/apache/hudi/integ/HoodieTestHiveBase.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.hudi.integ;
+
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.util.collection.Pair;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Base class to run cmd and generate data in hive.
+ */
+public class HoodieTestHiveBase extends ITTestBase {
+
+  protected enum PartitionType {
+    SINGLE_KEY_PARTITIONED, MULTI_KEYS_PARTITIONED, NON_PARTITIONED,
+  }
+
+  /**
+   * A basic integration test that runs HoodieJavaApp to create a sample 
Hoodie data-set and performs upserts on it.
+   * Hive integration and upsert functionality is checked by running a count 
query in hive console. TODO: Add
+   * spark-shell test-case
+   */
+  public void generateDataByHoodieJavaApp(String hiveTableName, String 
tableType, PartitionType partitionType,
+      String commitType, String hoodieTableName) throws Exception {
+
+    String hdfsPath = getHdfsPath(hiveTableName);
+    String hdfsUrl = "hdfs://namenode" + hdfsPath;
+
+    // Drop Table if it exists
+    try {
+      dropHiveTables(hiveTableName, tableType);
+    } catch (AssertionError ex) {
+      // In travis, sometimes, the hivemetastore is not ready even though we 
wait for the port to be up
+      // Workaround to sleep for 5 secs and retry
+      Thread.sleep(5000);
+      dropHiveTables(hiveTableName, tableType);
+    }
+
+    // Ensure table does not exist
+    Pair<String, String> stdOutErr = null;
+    if (commitType == "overwrite") {

Review comment:
       Replace `==` to `equal` method

##########
File path: 
hudi-integ-test/src/test/java/org/apache/hudi/integ/HoodieTestHiveBase.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.hudi.integ;
+
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.util.collection.Pair;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Base class to run cmd and generate data in hive.
+ */
+public class HoodieTestHiveBase extends ITTestBase {
+
+  protected enum PartitionType {
+    SINGLE_KEY_PARTITIONED, MULTI_KEYS_PARTITIONED, NON_PARTITIONED,
+  }
+
+  /**
+   * A basic integration test that runs HoodieJavaApp to create a sample 
Hoodie data-set and performs upserts on it.
+   * Hive integration and upsert functionality is checked by running a count 
query in hive console. TODO: Add
+   * spark-shell test-case
+   */
+  public void generateDataByHoodieJavaApp(String hiveTableName, String 
tableType, PartitionType partitionType,
+      String commitType, String hoodieTableName) throws Exception {
+
+    String hdfsPath = getHdfsPath(hiveTableName);
+    String hdfsUrl = "hdfs://namenode" + hdfsPath;
+
+    // Drop Table if it exists
+    try {
+      dropHiveTables(hiveTableName, tableType);
+    } catch (AssertionError ex) {
+      // In travis, sometimes, the hivemetastore is not ready even though we 
wait for the port to be up
+      // Workaround to sleep for 5 secs and retry
+      Thread.sleep(5000);
+      dropHiveTables(hiveTableName, tableType);
+    }
+
+    // Ensure table does not exist
+    Pair<String, String> stdOutErr = null;
+    if (commitType == "overwrite") {
+      stdOutErr = executeHiveCommand("show tables like '" + hiveTableName + 
"'");
+      assertTrue(stdOutErr.getLeft().isEmpty(), "Dropped table " + 
hiveTableName + " exists!");
+    }
+
+    // Run Hoodie Java App
+    String cmd = HOODIE_JAVA_APP + " HoodieJavaGenerateApp --hive-sync 
--table-path " + hdfsUrl + " --hive-url " + HIVE_SERVER_JDBC_URL

Review comment:
       Let's use `String.format()`?

##########
File path: 
hudi-integ-test/src/test/java/org/apache/hudi/integ/HoodieTestHiveBase.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.hudi.integ;
+
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.util.collection.Pair;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Base class to run cmd and generate data in hive.
+ */
+public class HoodieTestHiveBase extends ITTestBase {
+
+  protected enum PartitionType {
+    SINGLE_KEY_PARTITIONED, MULTI_KEYS_PARTITIONED, NON_PARTITIONED,
+  }
+
+  /**
+   * A basic integration test that runs HoodieJavaApp to create a sample 
Hoodie data-set and performs upserts on it.
+   * Hive integration and upsert functionality is checked by running a count 
query in hive console. TODO: Add
+   * spark-shell test-case
+   */
+  public void generateDataByHoodieJavaApp(String hiveTableName, String 
tableType, PartitionType partitionType,
+      String commitType, String hoodieTableName) throws Exception {
+
+    String hdfsPath = getHdfsPath(hiveTableName);
+    String hdfsUrl = "hdfs://namenode" + hdfsPath;
+
+    // Drop Table if it exists
+    try {
+      dropHiveTables(hiveTableName, tableType);
+    } catch (AssertionError ex) {
+      // In travis, sometimes, the hivemetastore is not ready even though we 
wait for the port to be up
+      // Workaround to sleep for 5 secs and retry
+      Thread.sleep(5000);

Review comment:
       Let's make it configurable?

##########
File path: 
hudi-integ-test/src/test/java/org/apache/hudi/integ/HoodieTestHiveBase.java
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.hudi.integ;
+
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.common.util.collection.Pair;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Base class to run cmd and generate data in hive.
+ */
+public class HoodieTestHiveBase extends ITTestBase {
+
+  protected enum PartitionType {
+    SINGLE_KEY_PARTITIONED, MULTI_KEYS_PARTITIONED, NON_PARTITIONED,
+  }
+
+  /**
+   * A basic integration test that runs HoodieJavaApp to create a sample 
Hoodie data-set and performs upserts on it.
+   * Hive integration and upsert functionality is checked by running a count 
query in hive console. TODO: Add
+   * spark-shell test-case
+   */
+  public void generateDataByHoodieJavaApp(String hiveTableName, String 
tableType, PartitionType partitionType,
+      String commitType, String hoodieTableName) throws Exception {
+
+    String hdfsPath = getHdfsPath(hiveTableName);
+    String hdfsUrl = "hdfs://namenode" + hdfsPath;
+
+    // Drop Table if it exists
+    try {
+      dropHiveTables(hiveTableName, tableType);
+    } catch (AssertionError ex) {
+      // In travis, sometimes, the hivemetastore is not ready even though we 
wait for the port to be up
+      // Workaround to sleep for 5 secs and retry
+      Thread.sleep(5000);
+      dropHiveTables(hiveTableName, tableType);
+    }
+
+    // Ensure table does not exist
+    Pair<String, String> stdOutErr = null;

Review comment:
       No need to initialize it to be `null`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to