zhangbutao commented on code in PR #5992:
URL: https://github.com/apache/hive/pull/5992#discussion_r2231348442


##########
itests/test-jdbc/src/test/java/org/apache/hive/jdbc/ITHiveServer2.java:
##########
@@ -0,0 +1,270 @@
+/*
+ * 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.hive.jdbc;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.minikdc.MiniKdc;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
+import org.testcontainers.utility.DockerImageName;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class ITHiveServer2 extends ITAbstractContainer {
+  protected File workDir;
+  private final MiniJdbcKdc miniKdc;
+  protected GenericContainer<?> container;
+  protected final String imageName = "apache/hive:4.0.1";
+  private int[] realmPorts;
+
+  public ITHiveServer2() {
+    this.miniKdc = null;
+  }
+
+  public ITHiveServer2(File workDir) throws Exception {
+    this.workDir = new File(workDir, "test-standalone-jdbc-file");
+    this.miniKdc = new MiniJdbcKdc(this.workDir);
+
+    String principal = MiniJdbcKdc.HIVE_TEST_USER_1;
+    Configuration configuration = new Configuration();
+    configuration.set("hadoop.security.authentication", "kerberos");
+    UserGroupInformation.setConfiguration(configuration);
+    UserGroupInformation.loginUserFromKeytab(principal, 
miniKdc.getKeyTabFile(principal));
+    assertEquals(principal, 
UserGroupInformation.getLoginUser().getShortUserName());
+  }
+
+  protected Map<String, String> prepareEnvArgs() {
+    Map<String, String> envArgs = new HashMap<>();
+    envArgs.put("SERVICE_NAME", "hiveserver2");
+    envArgs.put("HIVE_SERVER2_TRANSPORT_MODE", "all");
+    List<String> properties = new ArrayList<>();
+    properties.add("hive.server2.authentication=KERBEROS");
+    
properties.add("hive.server2.authentication.kerberos.principal=hive/_HOST@" + 
miniKdc.getRealm());
+    
properties.add("hive.server2.authentication.kerberos.keytab=/opt/hive/conf/hive.keytab");
+    StringBuilder builder = new StringBuilder();
+    for (String prop : properties) {
+      builder.append("-D").append(prop).append(" ");
+    }
+    envArgs.put("SERVICE_OPTS", builder.toString());
+    return envArgs;
+  }
+
+  private Map<String, String> prepareFiles() {
+    Map<String, String> boundFiles = new HashMap<>();
+
+    boundFiles.put(createNewKrbConf().getPath(), "/etc/krb5.conf");
+    
boundFiles.put(miniKdc.getKeyTabFile(miniKdc.getServicePrincipalForUser("hive")),
 "/opt/hive/conf/hive.keytab");
+    StringBuilder core_site = new 
StringBuilder("<configuration>").append(System.lineSeparator());

Review Comment:
   Should we consider putting the content of core_site and yarn_site into local 
files core-site.xml and yarn-site.xml? This would make it easier to extend and 
add related configurations later without modifying the code here to add new 
configurations.



-- 
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: gitbox-unsubscr...@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to