You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/11/02 09:30:39 UTC

[GitHub] [hudi] codope commented on a change in pull request #3771: [HUDI-2402] Add Kerberos configuration options to Hive Sync

codope commented on a change in pull request #3771:
URL: https://github.com/apache/hudi/pull/3771#discussion_r740865098



##########
File path: hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/TestHiveSyncTool.java
##########
@@ -1017,4 +1019,36 @@ public void testTypeConverter(String syncMode) throws Exception {
         .containsValue("BIGINT"), errorMsg);
     ddlExecutor.runSQL(dropTableSql);
   }
+
+  @Test
+  public void testHiveSyncOfKerberosEnvironment() throws Exception {
+    // Path to the krb5 file
+    String ker5Path = "/krb5.conf";
+    // Path to the user keytab file
+    String principal = "/test.keytab";
+    // User Principal
+    String keytabPath = "test@HADOOP";
+    // Kerberos authentication of the client
+    System.setProperty("java.security.krb5.conf", ker5Path);
+    Configuration conf = new Configuration();
+    conf.set("hadoop.security.authentication", "kerberos");
+    UserGroupInformation.setConfiguration(conf);
+    UserGroupInformation.loginUserFromKeytab(principal, keytabPath);
+    // If flink or Spark is used, you need to use the Kerberos authentication method recommended by Flink or Spark
+
+    // Setting Kerberos Parameters
+    // Hive Principal
+    String hivePrincipal = "hive@HADOOP";
+    HiveTestUtil.hiveSyncConfig.useKerberos = true;
+    HiveTestUtil.hiveSyncConfig.kerberosPrincipal = hivePrincipal;
+    HiveSyncTool hiveSyncTool = new HiveSyncTool(hiveSyncConfig, HiveTestUtil.getHiveConf(), HiveTestUtil.fileSystem);
+    HoodieHiveClient hoodieHiveClient = hiveSyncTool.hoodieHiveClient;
+
+    // Create a database in Hive. If the database is created successfully
+    // the client synchronizes the Kerberos metadata for managing Hive
+    hoodieHiveClient.createDatabase(hiveSyncConfig.databaseName);
+
+    assert !hoodieHiveClient.doesDataBaseExist(hiveSyncConfig.databaseName) : "Database creation failed!";

Review comment:
       Shouldn't we actually assert that database exists instead of **!** condition? Why not simply write as below?
   ```
   assertTrue(hoodieHiveClient.doesDataBaseExist(hiveSyncConfig.databaseName));
   ```
   
   This is in convention with other tests.

##########
File path: hudi-sync/hudi-hive-sync/src/test/java/org/apache/hudi/hive/TestHiveSyncTool.java
##########
@@ -1017,4 +1019,36 @@ public void testTypeConverter(String syncMode) throws Exception {
         .containsValue("BIGINT"), errorMsg);
     ddlExecutor.runSQL(dropTableSql);
   }
+
+  @Test
+  public void testHiveSyncOfKerberosEnvironment() throws Exception {
+    // Path to the krb5 file
+    String ker5Path = "/krb5.conf";
+    // Path to the user keytab file
+    String principal = "/test.keytab";
+    // User Principal
+    String keytabPath = "test@HADOOP";
+    // Kerberos authentication of the client
+    System.setProperty("java.security.krb5.conf", ker5Path);
+    Configuration conf = new Configuration();
+    conf.set("hadoop.security.authentication", "kerberos");
+    UserGroupInformation.setConfiguration(conf);
+    UserGroupInformation.loginUserFromKeytab(principal, keytabPath);
+    // If flink or Spark is used, you need to use the Kerberos authentication method recommended by Flink or Spark
+
+    // Setting Kerberos Parameters
+    // Hive Principal
+    String hivePrincipal = "hive@HADOOP";
+    HiveTestUtil.hiveSyncConfig.useKerberos = true;
+    HiveTestUtil.hiveSyncConfig.kerberosPrincipal = hivePrincipal;
+    HiveSyncTool hiveSyncTool = new HiveSyncTool(hiveSyncConfig, HiveTestUtil.getHiveConf(), HiveTestUtil.fileSystem);
+    HoodieHiveClient hoodieHiveClient = hiveSyncTool.hoodieHiveClient;
+
+    // Create a database in Hive. If the database is created successfully
+    // the client synchronizes the Kerberos metadata for managing Hive
+    hoodieHiveClient.createDatabase(hiveSyncConfig.databaseName);
+
+    assert !hoodieHiveClient.doesDataBaseExist(hiveSyncConfig.databaseName) : "Database creation failed!";
+    System.out.println("Database created successfully: " + hiveSyncConfig.databaseName);

Review comment:
       Please remove the println statement. Consider using logger if necessary.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

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