diff --git itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java index 272c745a8f..febfcf5230 100644 --- itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java +++ itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStore.java @@ -51,13 +51,14 @@ public static void beforeTest() throws Exception { MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.WAREHOUSE)); System.setProperty(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname, MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.CONNECT_URL_KEY)); - // Before this patch, the Embedded MetaStore was used here not the one started by the MiniHS2 - // The below 3 lines would change the tests to use the Remote MetaStore, but it will cause a - // failure. By removing the thrift MetaStore uris, the tests are passing again. - // I think this is an valid problem here, but not really sure about the - // tests original intention, so keep everything as it was originally. -// System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname, -// MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.THRIFT_URIS)); -// Thread.sleep(2000); + System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname, + MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.THRIFT_URIS)); + System.setProperty(ConfVars.METASTORE_USE_THRIFT_SASL.varname, + String.valueOf(MetastoreConf.getBoolVar(hiveConf, MetastoreConf.ConfVars.USE_THRIFT_SASL))); + System.setProperty(HiveConf.ConfVars.METASTORE_KERBEROS_PRINCIPAL.varname, + MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.KERBEROS_PRINCIPAL)); + System.setProperty(ConfVars.METASTORE_KERBEROS_KEYTAB_FILE.varname, + MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.KERBEROS_KEYTAB_FILE)); + } } \ No newline at end of file diff --git itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java index 5b7fb7ea5d..136c966abe 100644 --- itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java +++ itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestJdbcWithDBTokenStoreNoDoAs.java @@ -53,6 +53,5 @@ public static void beforeTest() throws Exception { MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.CONNECT_URL_KEY)); System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname, MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.THRIFT_URIS)); - Thread.sleep(2000); } } \ No newline at end of file diff --git itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java index e5b100c549..baa36ba6e5 100644 --- itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java +++ itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java @@ -21,6 +21,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -609,8 +611,7 @@ public MiniDFSShim getDFS() { private void waitForStartup() throws Exception { int waitTime = 0; long startupTimeout = 1000L * 1000L; - CLIServiceClient hs2Client = getServiceClientInternal(); - SessionHandle sessionHandle = null; + Connection hs2Conn; do { Thread.sleep(500L); waitTime += 500L; @@ -618,23 +619,12 @@ private void waitForStartup() throws Exception { throw new TimeoutException("Couldn't access new HiveServer2: " + getJdbcURL()); } try { - Map sessionConf = new HashMap(); - /** - if (isUseMiniKdc()) { - getMiniKdc().loginUser(getMiniKdc().getDefaultUserPrincipal()); - sessionConf.put("principal", serverPrincipal); - } - */ - sessionHandle = hs2Client.openSession("foo", "bar", sessionConf); + hs2Conn = DriverManager.getConnection(getJdbcURL()); } catch (Exception e) { - if (e.getMessage().contains("Cannot open sessions on an inactive HS2")) { - // Passive HS2 has started. TODO: seems fragile - return; - } // service not started yet continue; } - hs2Client.closeSession(sessionHandle); + hs2Conn.close(); break; } while (true); }