Repository: hive
Updated Branches:
  refs/heads/storage-branch-2.6 a60871fd7 -> c055e8444 (forced update)


HIVE-19104: When test MetaStore is started with retry the instances should be 
independent (Peter Vary, reviewed by Sahil Takiar)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/5e0480e3
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/5e0480e3
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/5e0480e3

Branch: refs/heads/storage-branch-2.6
Commit: 5e0480e35f6176ff38ecffea64369287b87bd378
Parents: a1524f7
Author: Peter Vary <pv...@cloudera.com>
Authored: Mon Apr 23 10:10:39 2018 +0200
Committer: Peter Vary <pv...@cloudera.com>
Committed: Mon Apr 23 10:10:39 2018 +0200

----------------------------------------------------------------------
 .../apache/hive/hcatalog/cli/TestPermsGrp.java  | 13 ++++--
 .../mapreduce/TestHCatMultiOutputFormat.java    | 18 ++++----
 .../mapreduce/TestHCatPartitionPublish.java     | 15 ++++---
 .../hadoop/hive/ql/parse/WarehouseInstance.java |  2 +-
 .../org/apache/hive/jdbc/miniHS2/MiniHS2.java   |  7 +--
 .../hive/metastore/conf/MetastoreConf.java      |  4 +-
 .../hive/metastore/MetaStoreTestUtils.java      | 45 ++++++++++++++++++--
 .../hive/metastore/TestHiveMetaStore.java       | 13 +++---
 .../hive/metastore/TestRemoteHiveMetaStore.java |  1 -
 9 files changed, 82 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestPermsGrp.java
----------------------------------------------------------------------
diff --git 
a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestPermsGrp.java 
b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestPermsGrp.java
index 8a2151c..3c9d89a 100644
--- a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestPermsGrp.java
+++ b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestPermsGrp.java
@@ -43,6 +43,7 @@ import org.apache.hadoop.hive.metastore.api.SerDeInfo;
 import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.Type;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.ql.io.HiveInputFormat;
 import org.apache.hadoop.hive.ql.io.HiveOutputFormat;
 import org.apache.hadoop.hive.ql.metadata.Hive;
@@ -62,7 +63,6 @@ import junit.framework.TestCase;
 public class TestPermsGrp extends TestCase {
 
   private boolean isServerRunning = false;
-  private int msPort;
   private HiveConf hcatConf;
   private Warehouse clientWH;
   private HiveMetaStoreClient msc;
@@ -80,7 +80,8 @@ public class TestPermsGrp extends TestCase {
       return;
     }
 
-    msPort = MetaStoreTestUtils.startMetaStoreWithRetry();
+    hcatConf = new HiveConf(this.getClass());
+    MetaStoreTestUtils.startMetaStoreWithRetry(hcatConf);
 
     isServerRunning = true;
 
@@ -88,8 +89,6 @@ public class TestPermsGrp extends TestCase {
     System.setSecurityManager(new NoExitSecurityManager());
     Policy.setPolicy(new DerbyPolicy());
 
-    hcatConf = new HiveConf(this.getClass());
-    hcatConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://127.0.0.1:" + 
msPort);
     hcatConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
     hcatConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTFAILURERETRIES, 3);
 
@@ -102,6 +101,12 @@ public class TestPermsGrp extends TestCase {
     msc = new HiveMetaStoreClient(hcatConf);
     System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " ");
     System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " ");
+    System.setProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname,
+        MetastoreConf.getVar(hcatConf, MetastoreConf.ConfVars.WAREHOUSE));
+    System.setProperty(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname,
+        MetastoreConf.getVar(hcatConf, 
MetastoreConf.ConfVars.CONNECT_URL_KEY));
+    System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname,
+        MetastoreConf.getVar(hcatConf, MetastoreConf.ConfVars.THRIFT_URIS));
   }
 
   public void testCustomPerms() throws Exception {

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatMultiOutputFormat.java
----------------------------------------------------------------------
diff --git 
a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatMultiOutputFormat.java
 
b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatMultiOutputFormat.java
index d9de10e..8a8a326 100644
--- 
a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatMultiOutputFormat.java
+++ 
b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatMultiOutputFormat.java
@@ -90,9 +90,6 @@ public class TestHCatMultiOutputFormat {
   private static HiveConf hiveConf;
   private static File workDir;
 
-  private static int msPort;
-  private static Thread t;
-
   static {
     schemaMap.put(tableNames[0], new HCatSchema(ColumnHolder.hCattest1Cols));
     schemaMap.put(tableNames[1], new HCatSchema(ColumnHolder.hCattest2Cols));
@@ -162,7 +159,7 @@ public class TestHCatMultiOutputFormat {
     metastoreConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, 
warehousedir.toString());
 
     // Run hive metastore server
-    msPort = MetaStoreTestUtils.startMetaStoreWithRetry(metastoreConf);
+    MetaStoreTestUtils.startMetaStoreWithRetry(metastoreConf);
     // Read the warehouse dir, which can be changed so multiple MetaStore 
tests could be run on
     // the same server
     warehousedir = new Path(MetastoreConf.getVar(metastoreConf, 
MetastoreConf.ConfVars.WAREHOUSE));
@@ -178,15 +175,14 @@ public class TestHCatMultiOutputFormat {
       new JobConf(conf));
     mrConf = mrCluster.createJobConf();
 
-    initializeSetup();
+    initializeSetup(metastoreConf);
 
     warehousedir.getFileSystem(conf).mkdirs(warehousedir);
   }
 
-  private static void initializeSetup() throws Exception {
+  private static void initializeSetup(HiveConf metastoreConf) throws Exception 
{
 
-    hiveConf = new HiveConf(mrConf, TestHCatMultiOutputFormat.class);
-    hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + 
msPort);
+    hiveConf = new HiveConf(metastoreConf, TestHCatMultiOutputFormat.class);
     hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
     hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTFAILURERETRIES, 3);
     hiveConf.set(HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK.varname,
@@ -196,6 +192,12 @@ public class TestHCatMultiOutputFormat {
     hiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
     System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " ");
     System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " ");
+    System.setProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname,
+        MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.WAREHOUSE));
+    System.setProperty(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname,
+        MetastoreConf.getVar(hiveConf, 
MetastoreConf.ConfVars.CONNECT_URL_KEY));
+    System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname,
+        MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.THRIFT_URIS));
 
     hiveConf.set(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, 
warehousedir.toString());
     try {

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatPartitionPublish.java
----------------------------------------------------------------------
diff --git 
a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatPartitionPublish.java
 
b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatPartitionPublish.java
index fb6a7f4..cd7dd83 100644
--- 
a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatPartitionPublish.java
+++ 
b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatPartitionPublish.java
@@ -43,6 +43,7 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.SerDeInfo;
 import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
 import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge;
 import org.apache.hadoop.hive.ql.io.RCFileInputFormat;
 import org.apache.hadoop.hive.ql.io.RCFileOutputFormat;
@@ -73,7 +74,6 @@ public class TestHCatPartitionPublish {
   private static FileSystem fs = null;
   private static MiniMRCluster mrCluster = null;
   private static boolean isServerRunning = false;
-  private static int msPort;
   private static HiveConf hcatConf;
   private static HiveMetaStoreClient msc;
   private static SecurityManager securityManager;
@@ -106,17 +106,14 @@ public class TestHCatPartitionPublish {
       return;
     }
 
-    msPort = MetaStoreTestUtils.startMetaStoreWithRetry();
+    hcatConf = new HiveConf(TestHCatPartitionPublish.class);
+    MetaStoreTestUtils.startMetaStoreWithRetry(hcatConf);
 
-    Thread.sleep(10000);
     isServerRunning = true;
     securityManager = System.getSecurityManager();
     System.setSecurityManager(new NoExitSecurityManager());
     Policy.setPolicy(new DerbyPolicy());
 
-    hcatConf = new HiveConf(TestHCatPartitionPublish.class);
-    hcatConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:"
-        + msPort);
     hcatConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
     hcatConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTFAILURERETRIES, 3);
     hcatConf.setTimeVar(HiveConf.ConfVars.METASTORE_CLIENT_SOCKET_TIMEOUT, 
120, TimeUnit.SECONDS);
@@ -129,6 +126,12 @@ public class TestHCatPartitionPublish {
     msc = new HiveMetaStoreClient(hcatConf);
     System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " ");
     System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " ");
+    System.setProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname,
+        MetastoreConf.getVar(hcatConf, MetastoreConf.ConfVars.WAREHOUSE));
+    System.setProperty(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname,
+        MetastoreConf.getVar(hcatConf, 
MetastoreConf.ConfVars.CONNECT_URL_KEY));
+    System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname,
+        MetastoreConf.getVar(hcatConf, MetastoreConf.ConfVars.THRIFT_URIS));
   }
 
   @AfterClass

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
----------------------------------------------------------------------
diff --git 
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
 
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
index accdc1f..f95e1c6 100644
--- 
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
+++ 
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/WarehouseInstance.java
@@ -129,7 +129,7 @@ public class WarehouseInstance implements Closeable {
     System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " ");
     System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " ");
 
-    MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf);
+    MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf, true);
 
     Path testPath = new Path(hiveWarehouseLocation);
     FileSystem testPathFileSystem = FileSystem.get(testPath.toUri(), hiveConf);

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
----------------------------------------------------------------------
diff --git 
a/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java 
b/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
index cafdb98..13b534e 100644
--- a/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
+++ b/itests/util/src/main/java/org/apache/hive/jdbc/miniHS2/MiniHS2.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.llap.LlapItUtils;
 import org.apache.hadoop.hive.llap.daemon.MiniLlapCluster;
 import org.apache.hadoop.hive.metastore.MetaStoreTestUtils;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.ql.exec.Utilities;
 import org.apache.hadoop.hive.ql.util.ZooKeeperHiveHelper;
 import org.apache.hadoop.hive.shims.HadoopShims.MiniDFSShim;
@@ -288,9 +289,6 @@ public class MiniHS2 extends AbstractHiveService {
       hiveConf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, authType);
     }
 
-    String metaStoreURL = "jdbc:derby:;databaseName=" + 
baseDir.getAbsolutePath() + File.separator
-        + "test_metastore;create=true";
-
     if (isMetastoreSecure) {
       hiveConf.setVar(ConfVars.METASTORE_KERBEROS_PRINCIPAL, 
metastoreServerPrincipal);
       hiveConf.setVar(ConfVars.METASTORE_KERBEROS_KEYTAB_FILE, 
metastoreKeyTab);
@@ -304,8 +302,6 @@ public class MiniHS2 extends AbstractHiveService {
 
     fs.mkdirs(wareHouseDir);
     setWareHouseDir(wareHouseDir.toString());
-    System.setProperty(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname, 
metaStoreURL);
-    hiveConf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY, metaStoreURL);
     if (!usePortsFromConf) {
       // reassign a new port, just in case if one of the MR services grabbed 
the last one
       setBinaryPort(MetaStoreTestUtils.findFreePort());
@@ -344,6 +340,7 @@ public class MiniHS2 extends AbstractHiveService {
   public void start(Map<String, String> confOverlay) throws Exception {
     if (isMetastoreRemote) {
       MetaStoreTestUtils.startMetaStoreWithRetry(getHiveConf());
+      setWareHouseDir(MetastoreConf.getVar(getHiveConf(), 
MetastoreConf.ConfVars.WAREHOUSE));
     }
 
     // Set confOverlay parameters

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
 
b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
index 88b07cb..59749e4 100644
--- 
a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
+++ 
b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
@@ -1102,8 +1102,10 @@ public class MetastoreConf {
   }
 
   public static Configuration newMetastoreConf() {
+    return newMetastoreConf(new Configuration());
+  }
 
-    Configuration conf = new Configuration();
+  public static Configuration newMetastoreConf(Configuration conf) {
 
     ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
     if (classLoader == null) {

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
 
b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
index 1d12cf9..3d36b60 100644
--- 
a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
+++ 
b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java
@@ -27,7 +27,10 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
 import org.apache.hadoop.hive.metastore.events.EventCleanerTask;
@@ -40,6 +43,7 @@ import static 
org.apache.hadoop.hive.metastore.Warehouse.DEFAULT_CATALOG_NAME;
 
 public class MetaStoreTestUtils {
   private static final Logger LOG = 
LoggerFactory.getLogger(MetaStoreTestUtils.class);
+  private static final String TMP_DIR = System.getProperty("test.tmp.dir");
   public static final int RETRY_COUNT = 10;
 
   /**
@@ -82,11 +86,22 @@ public class MetaStoreTestUtils {
     return 
MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), 
conf);
   }
 
+  public static int startMetaStoreWithRetry(Configuration conf, boolean 
keepJdbcUri)
+      throws Exception {
+    return 
MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), 
conf,
+        keepJdbcUri);
+  }
+
   public static int startMetaStoreWithRetry() throws Exception {
     return 
MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(),
         MetastoreConf.newMetastoreConf());
   }
 
+  public static int startMetaStoreWithRetry(HadoopThriftAuthBridge bridge,
+                                            Configuration conf) throws 
Exception {
+    return MetaStoreTestUtils.startMetaStoreWithRetry(bridge, conf, false);
+  }
+
   /**
    * Starts a MetaStore instance with the given configuration and given bridge.
    * Tries to find a free port, and use it. If failed tries another port so 
the tests will not
@@ -94,22 +109,46 @@ public class MetaStoreTestUtils {
    * instances will use different warehouse directories.
    * @param bridge The Thrift bridge to uses
    * @param conf The configuration to use
+   * @param keepJdbcUri If set to true, then the JDBC url is not changed
    * @return The port on which the MetaStore finally started
    * @throws Exception
    */
   public static int startMetaStoreWithRetry(HadoopThriftAuthBridge bridge,
-                                            Configuration conf) throws 
Exception {
+      Configuration conf, boolean keepJdbcUri) throws Exception {
     Exception metaStoreException = null;
     String warehouseDir = MetastoreConf.getVar(conf, ConfVars.WAREHOUSE);
+
     for (int tryCount = 0; tryCount < MetaStoreTestUtils.RETRY_COUNT; 
tryCount++) {
       try {
         int metaStorePort = findFreePort();
+        // Setting metastore instance specific warehouse directory, postfixing 
with port
         Path postfixedWarehouseDir = new Path(warehouseDir, 
String.valueOf(metaStorePort));
         MetastoreConf.setVar(conf, ConfVars.WAREHOUSE, 
postfixedWarehouseDir.toString());
+
+        String jdbcUrl = MetastoreConf.getVar(conf, ConfVars.CONNECT_URL_KEY);
+        if (!keepJdbcUri) {
+          // Setting metastore instance specific jdbc url postfixed with port
+          jdbcUrl = "jdbc:derby:;databaseName=" + TMP_DIR + File.separator
+              + "junit_metastore_db_" + metaStorePort + ";create=true";
+          MetastoreConf.setVar(conf, ConfVars.CONNECT_URL_KEY, jdbcUrl);
+        }
+
+        // Setting metastore instance specific metastore uri
         MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" 
+ metaStorePort);
         MetaStoreTestUtils.startMetaStore(metaStorePort, bridge, conf);
-        LOG.error("MetaStore Thrift Server started on port: {} with warehouse 
dir: {}",
-            metaStorePort, postfixedWarehouseDir);
+
+        // Creating warehouse dir, if not exists
+        Warehouse wh = new Warehouse(conf);
+        if (!wh.isDir(wh.getWhRoot())) {
+          FileSystem fs = wh.getWhRoot().getFileSystem(conf);
+          fs.mkdirs(wh.getWhRoot());
+          fs.setPermission(wh.getWhRoot(),
+              new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
+          LOG.info("MetaStore warehouse root dir ({}) is created", 
postfixedWarehouseDir);
+        }
+
+        LOG.info("MetaStore Thrift Server started on port: {} with warehouse 
dir: {} with " +
+            "jdbcUrl: {}", metaStorePort, postfixedWarehouseDir, jdbcUrl);
         return metaStorePort;
       } catch (ConnectException ce) {
         metaStoreException = ce;

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
 
b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
index 6f52a52..cb32236 100644
--- 
a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
+++ 
b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
@@ -100,7 +100,7 @@ import static org.junit.Assert.fail;
 public abstract class TestHiveMetaStore {
   private static final Logger LOG = 
LoggerFactory.getLogger(TestHiveMetaStore.class);
   protected static HiveMetaStoreClient client;
-  protected static Configuration conf;
+  protected static Configuration conf = MetastoreConf.newMetastoreConf();
   protected static Warehouse warehouse;
   protected static boolean isThriftClient = false;
 
@@ -113,7 +113,6 @@ public abstract class TestHiveMetaStore {
 
   @Before
   public void setUp() throws Exception {
-    conf = MetastoreConf.newMetastoreConf();
     warehouse = new Warehouse(conf);
 
     // set some values to use for getting conf. vars
@@ -2928,18 +2927,18 @@ public abstract class TestHiveMetaStore {
   @Test
   public void testRetriableClientWithConnLifetime() throws Exception {
 
-    Configuration conf = MetastoreConf.newMetastoreConf();
-    MetastoreConf.setTimeVar(conf, ConfVars.CLIENT_SOCKET_LIFETIME, 4, 
TimeUnit.SECONDS);
-    MetaStoreTestUtils.setConfForStandloneMode(conf);
+    Configuration newConf = MetastoreConf.newMetastoreConf(new 
Configuration(this.conf));
+    MetastoreConf.setTimeVar(newConf, ConfVars.CLIENT_SOCKET_LIFETIME, 4, 
TimeUnit.SECONDS);
+    MetaStoreTestUtils.setConfForStandloneMode(newConf);
     long timeout = 5 * 1000; // Lets use a timeout more than the socket 
lifetime to simulate a reconnect
 
     // Test a normal retriable client
-    IMetaStoreClient client = RetryingMetaStoreClient.getProxy(conf, 
getHookLoader(), HiveMetaStoreClient.class.getName());
+    IMetaStoreClient client = RetryingMetaStoreClient.getProxy(newConf, 
getHookLoader(), HiveMetaStoreClient.class.getName());
     client.getAllDatabases();
     client.close();
 
     // Connect after the lifetime, there should not be any failures
-    client = RetryingMetaStoreClient.getProxy(conf, getHookLoader(), 
HiveMetaStoreClient.class.getName());
+    client = RetryingMetaStoreClient.getProxy(newConf, getHookLoader(), 
HiveMetaStoreClient.class.getName());
     Thread.sleep(timeout);
     client.getAllDatabases();
     client.close();

http://git-wip-us.apache.org/repos/asf/hive/blob/5e0480e3/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java
 
b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java
index e1f81bb..415988d 100644
--- 
a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java
+++ 
b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStore.java
@@ -43,7 +43,6 @@ public class TestRemoteHiveMetaStore extends 
TestHiveMetaStore {
 
     if (isServerStarted) {
       Assert.assertNotNull("Unable to connect to the MetaStore server", 
client);
-      MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + 
port);
       return;
     }
 

Reply via email to