You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pv...@apache.org on 2018/03/23 12:54:55 UTC

hive git commit: Revert "kkk"

Repository: hive
Updated Branches:
  refs/heads/master f54ce4b4b -> f60aec0a5


Revert "kkk"

This reverts commit f54ce4b4b893af61839c58116cc542aa3f98a6c5.


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

Branch: refs/heads/master
Commit: f60aec0a5cab3b234263876ddcae2f0c309435e0
Parents: f54ce4b
Author: Peter Vary <pv...@cloudera.com>
Authored: Fri Mar 23 13:54:45 2018 +0100
Committer: Peter Vary <pv...@cloudera.com>
Committed: Fri Mar 23 13:54:45 2018 +0100

----------------------------------------------------------------------
 .../mapreduce/TestHCatMultiOutputFormat.java    |  6 +-
 .../hive/hcatalog/api/TestHCatClient.java       |  7 +-
 .../security/TestHadoopAuthBridge23.java        |  8 +-
 .../AbstractTestAuthorizationApiAuthorizer.java |  3 +-
 .../metastore/TestMetaStoreAuthorization.java   | 18 ++++-
 .../hive/metastore/TestMetaStoreMetrics.java    |  4 +-
 .../hive/ql/parse/TestReplicationScenarios.java | 13 ++--
 .../hadoop/hive/ql/parse/WarehouseInstance.java |  3 +-
 .../security/StorageBasedMetastoreTestBase.java |  3 +-
 .../org/apache/hive/jdbc/miniHS2/MiniHS2.java   |  3 +-
 .../hadoop/hive/ql/metadata/TestHiveRemote.java |  2 +-
 .../hive/metastore/MetaStoreTestUtils.java      | 77 ++++++++++----------
 .../hadoop/hive/metastore/TestFilterHooks.java  |  3 +-
 .../TestHiveMetaStorePartitionSpecs.java        |  2 +-
 ...TestHiveMetaStoreWithEnvironmentContext.java |  3 +-
 .../hive/metastore/TestMarkPartitionRemote.java |  7 +-
 .../TestMetaStoreEndFunctionListener.java       |  3 +-
 .../metastore/TestMetaStoreEventListener.java   |  3 +-
 .../TestMetaStoreEventListenerOnlyOnCommit.java |  3 +-
 .../TestMetaStoreEventListenerWithOldConf.java  |  4 +-
 .../metastore/TestMetaStoreInitListener.java    |  3 +-
 .../TestRemoteHiveMetaStoreIpAddress.java       |  4 +-
 .../hive/metastore/TestRetryingHMSHandler.java  |  3 +-
 .../metastore/client/TestAlterPartitions.java   | 16 ++--
 .../minihms/RemoteMetaStoreForTests.java        |  4 +-
 25 files changed, 123 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/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..7de2bbf 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
@@ -40,7 +40,6 @@ import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
 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.ql.CompilationOpContext;
 import org.apache.hadoop.hive.ql.QueryState;
 import org.apache.hadoop.hive.ql.exec.FetchTask;
@@ -162,10 +161,7 @@ public class TestHCatMultiOutputFormat {
     metastoreConf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, warehousedir.toString());
 
     // Run hive metastore server
-    msPort = 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));
+    msPort = MetaStoreTestUtils.startMetaStore(metastoreConf);
     // LocalJobRunner does not work with mapreduce OutputCommitter. So need
     // to use MiniMRCluster. MAPREDUCE-2350
     Configuration conf = new Configuration(true);

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
----------------------------------------------------------------------
diff --git a/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java b/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
index f9ee9d9..515eef2 100644
--- a/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
+++ b/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
@@ -120,7 +120,7 @@ public class TestHCatClient {
 
     System.setProperty(HiveConf.ConfVars.METASTORE_TRANSACTIONAL_EVENT_LISTENERS.varname,
         DbNotificationListener.class.getName()); // turn on db notification listener on metastore
-    msPort = MetaStoreTestUtils.startMetaStoreWithRetry();
+    msPort = MetaStoreTestUtils.startMetaStore();
     securityManager = System.getSecurityManager();
     System.setSecurityManager(new NoExitSecurityManager());
     Policy.setPolicy(new DerbyPolicy());
@@ -178,8 +178,7 @@ public class TestHCatClient {
     if (useExternalMS) {
       assertTrue(testDb.getLocation().matches(".*" + "/" + db + ".db"));
     } else {
-      String expectedDir = warehouseDir.replaceFirst("pfile:///", "pfile:/")
-          + "/" + msPort;
+      String expectedDir = warehouseDir.replaceFirst("pfile:///", "pfile:/");
       assertEquals(expectedDir + "/" + db + ".db", testDb.getLocation());
     }
     ArrayList<HCatFieldSchema> cols = new ArrayList<HCatFieldSchema>();
@@ -810,7 +809,7 @@ public class TestHCatClient {
       HiveConf conf = new HiveConf();
       conf.set("javax.jdo.option.ConnectionURL", hcatConf.get("javax.jdo.option.ConnectionURL")
         .replace("metastore", "target_metastore"));
-      replicationTargetHCatPort = MetaStoreTestUtils.startMetaStoreWithRetry(conf);
+      replicationTargetHCatPort = MetaStoreTestUtils.startMetaStore(conf);
       replicationTargetHCatConf = new HiveConf(hcatConf);
       replicationTargetHCatConf.setVar(HiveConf.ConfVars.METASTOREURIS,
                                        "thrift://localhost:" + replicationTargetHCatPort);

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/metastore/security/TestHadoopAuthBridge23.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/metastore/security/TestHadoopAuthBridge23.java b/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/metastore/security/TestHadoopAuthBridge23.java
index 6e651fa..f979baf 100644
--- a/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/metastore/security/TestHadoopAuthBridge23.java
+++ b/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/metastore/security/TestHadoopAuthBridge23.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.metastore.security;
 
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.HiveMetaStore;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
@@ -139,12 +140,17 @@ public class TestHadoopAuthBridge23 {
   @Before
   public void setup() throws Exception {
     isMetastoreTokenManagerInited = false;
+    int port = findFreePort();
     System.setProperty(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL.varname,
         "true");
+    System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname,
+        "thrift://localhost:" + port);
+    System.setProperty(HiveConf.ConfVars.METASTOREWAREHOUSE.varname, new Path(
+        System.getProperty("test.build.data", "/tmp")).toString());
     System.setProperty(HiveConf.ConfVars.METASTORE_CLUSTER_DELEGATION_TOKEN_STORE_CLS.varname,
         MyTokenStore.class.getName());
     conf = new HiveConf(TestHadoopAuthBridge23.class);
-    MetaStoreTestUtils.startMetaStoreWithRetry(new MyHadoopThriftAuthBridge23(), conf);
+    MetaStoreTestUtils.startMetaStore(port, new MyHadoopThriftAuthBridge23());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/AbstractTestAuthorizationApiAuthorizer.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/AbstractTestAuthorizationApiAuthorizer.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/AbstractTestAuthorizationApiAuthorizer.java
index abd5e32..439cf56 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/AbstractTestAuthorizationApiAuthorizer.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/AbstractTestAuthorizationApiAuthorizer.java
@@ -58,7 +58,8 @@ public abstract class AbstractTestAuthorizationApiAuthorizer {
 
     hiveConf = new HiveConf();
     if (isRemoteMetastoreMode) {
-      MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf);
+      int port = MetaStoreTestUtils.startMetaStoreWithRetry();
+      hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + port);
     }
     hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
     hiveConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreAuthorization.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreAuthorization.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreAuthorization.java
index 747efd8..6c4491e 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreAuthorization.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreAuthorization.java
@@ -18,6 +18,8 @@
 
 package org.apache.hadoop.hive.metastore;
 
+import java.io.IOException;
+import java.net.ServerSocket;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hadoop.fs.FileSystem;
@@ -28,6 +30,7 @@ import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.metastore.api.MetaException;
 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
+import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge;
 
 import junit.framework.TestCase;
 
@@ -38,13 +41,17 @@ public class TestMetaStoreAuthorization extends TestCase {
   private int port;
 
   public void setup() throws Exception {
-    conf.setBoolVar(HiveConf.ConfVars.METASTORE_AUTHORIZATION_STORAGE_AUTH_CHECKS, true);
+    port = findFreePort();
+    System.setProperty(HiveConf.ConfVars.METASTORE_AUTHORIZATION_STORAGE_AUTH_CHECKS.varname,
+        "true");
+    conf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + port);
     conf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
     conf.setTimeVar(ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY, 60, TimeUnit.SECONDS);
   }
 
   public void testIsWritable() throws Exception {
     setup();
+    conf = new HiveConf(this.getClass());
     String testDir = System.getProperty("test.warehouse.dir", "/tmp");
     Path testDirPath = new Path(testDir);
     FileSystem fs = testDirPath.getFileSystem(conf);
@@ -68,7 +75,7 @@ public class TestMetaStoreAuthorization extends TestCase {
 
   public void testMetaStoreAuthorization() throws Exception {
     setup();
-    MetaStoreTestUtils.startMetaStoreWithRetry(conf);
+    MetaStoreTestUtils.startMetaStore(port, HadoopThriftAuthBridge.getBridge());
     HiveMetaStoreClient client = new HiveMetaStoreClient(conf);
 
     FileSystem fs = null;
@@ -109,4 +116,11 @@ public class TestMetaStoreAuthorization extends TestCase {
       }
     }
   }
+
+  private int findFreePort() throws IOException {
+    ServerSocket socket= new ServerSocket(0);
+    int port = socket.getLocalPort();
+    socket.close();
+    return port;
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
index 368d517..25186c9 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java
@@ -49,7 +49,9 @@ public class TestMetaStoreMetrics {
             "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
 
     //Increments one HMS connection
-    MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf);
+
+    hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + port);
 
     //Increments one HMS connection (Hive.get())
     SessionState.start(new CliSessionState(hiveConf));

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
index 0940938..c383a53 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java
@@ -46,7 +46,6 @@ import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
 import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.UniqueConstraintsRequest;
-import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
 import org.apache.hadoop.hive.metastore.messaging.MessageFactory;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.AndFilter;
 import org.apache.hadoop.hive.metastore.messaging.event.filters.DatabaseAndTableFilter;
@@ -102,10 +101,12 @@ public class TestReplicationScenarios {
       System.getProperty("test.warehouse.dir", "/tmp") + Path.SEPARATOR + tid;
 
   private static HiveConf hconf;
+  private static int msPort;
   private static IDriver driver;
   private static HiveMetaStoreClient metaStoreClient;
   private static String proxySettingName;
   static HiveConf hconfMirror;
+  static int msPortMirror;
   static IDriver driverMirror;
   static HiveMetaStoreClient metaStoreClientMirror;
 
@@ -141,8 +142,10 @@ public class TestReplicationScenarios {
     hconf.setVar(HiveConf.ConfVars.REPLCMDIR, TEST_PATH + "/cmroot/");
     proxySettingName = "hadoop.proxyuser." + Utils.getUGI().getShortUserName() + ".hosts";
     hconf.set(proxySettingName, "*");
-    MetaStoreTestUtils.startMetaStoreWithRetry(hconf);
+    msPort = MetaStoreTestUtils.startMetaStore(hconf);
     hconf.setVar(HiveConf.ConfVars.REPLDIR,TEST_PATH + "/hrepl/");
+    hconf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:"
+        + msPort);
     hconf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
     hconf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
     hconf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
@@ -167,10 +170,10 @@ public class TestReplicationScenarios {
     FileUtils.deleteDirectory(new File("metastore_db2"));
     HiveConf hconfMirrorServer = new HiveConf();
     hconfMirrorServer.set(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname, "jdbc:derby:;databaseName=metastore_db2;create=true");
-    MetaStoreTestUtils.startMetaStoreWithRetry(hconfMirrorServer);
+    msPortMirror = MetaStoreTestUtils.startMetaStore(hconfMirrorServer);
     hconfMirror = new HiveConf(hconf);
-    String thriftUri = MetastoreConf.getVar(hconfMirrorServer, MetastoreConf.ConfVars.THRIFT_URIS);
-    MetastoreConf.setVar(hconfMirror, MetastoreConf.ConfVars.THRIFT_URIS, thriftUri);
+    hconfMirror.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:"
+        + msPortMirror);
     driverMirror = DriverFactory.newDriver(hconfMirror);
     metaStoreClientMirror = new HiveMetaStoreClient(hconfMirror);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/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 bc70fe4..feb1191 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
@@ -126,7 +126,8 @@ public class WarehouseInstance implements Closeable {
     System.setProperty(HiveConf.ConfVars.PREEXECHOOKS.varname, " ");
     System.setProperty(HiveConf.ConfVars.POSTEXECHOOKS.varname, " ");
 
-    MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf);
+    int metaStorePort = MetaStoreTestUtils.startMetaStore(hiveConf);
+    hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + metaStorePort);
 
     Path testPath = new Path(hiveWarehouseLocation);
     FileSystem testPathFileSystem = FileSystem.get(testPath.toUri(), hiveConf);

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/StorageBasedMetastoreTestBase.java
----------------------------------------------------------------------
diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/StorageBasedMetastoreTestBase.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/StorageBasedMetastoreTestBase.java
index b3383d9..1729893 100644
--- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/StorageBasedMetastoreTestBase.java
+++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/StorageBasedMetastoreTestBase.java
@@ -72,11 +72,12 @@ public class StorageBasedMetastoreTestBase {
         InjectableDummyAuthenticator.class.getName());
 
     clientHiveConf = createHiveConf();
-    MetaStoreTestUtils.startMetaStoreWithRetry(clientHiveConf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(clientHiveConf);
 
     // Turn off client-side authorization
     clientHiveConf.setBoolVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_ENABLED,false);
 
+    clientHiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + port);
     clientHiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
     clientHiveConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "false");
 

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/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 adf7018..e1c2dd0 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
@@ -339,7 +339,8 @@ public class MiniHS2 extends AbstractHiveService {
 
   public void start(Map<String, String> confOverlay) throws Exception {
     if (isMetastoreRemote) {
-      MetaStoreTestUtils.startMetaStoreWithRetry(getHiveConf());
+      int metaStorePort = MetaStoreTestUtils.startMetaStoreWithRetry(getHiveConf());
+      getHiveConf().setVar(ConfVars.METASTOREURIS, "thrift://localhost:" + metaStorePort);
     }
 
     // Set confOverlay parameters

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveRemote.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveRemote.java b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveRemote.java
index eccca48..08536f0 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveRemote.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveRemote.java
@@ -43,7 +43,7 @@ public class TestHiveRemote extends TestHive {
     hiveConf
     .setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER,
         "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory");
-    MetaStoreTestUtils.startMetaStoreWithRetry(hiveConf);
+    hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:" + MetaStoreTestUtils.startMetaStore());
 
     try {
       hm = Hive.get(hiveConf);

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/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 60fcb86..d4820b3 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
@@ -25,7 +25,6 @@ import java.net.Socket;
 import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
 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;
@@ -34,19 +33,30 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MetaStoreTestUtils {
+
   private static final Logger LOG = LoggerFactory.getLogger(MetaStoreTestUtils.class);
   public static final int RETRY_COUNT = 10;
 
-  /**
-   * Starts a MetaStore instance on get given port with the given configuration and Thrift bridge.
-   * Use it only it the port is definitely free. For tests use startMetaStoreWithRetry instead so
-   * the MetaStore will find an emtpy port eventually, so the different tests can be run on the
-   * same machine.
-   * @param port The port to start on
-   * @param bridge The bridge to use
-   * @param conf The configuration to use
-   * @throws Exception
-   */
+  public static int startMetaStore() throws Exception {
+    return MetaStoreTestUtils.startMetaStore(HadoopThriftAuthBridge.getBridge(), null);
+  }
+
+  public static int startMetaStore(final HadoopThriftAuthBridge bridge, Configuration conf)
+      throws Exception {
+    int port = MetaStoreTestUtils.findFreePort();
+    MetaStoreTestUtils.startMetaStore(port, bridge, conf);
+    return port;
+  }
+
+  public static int startMetaStore(Configuration conf) throws Exception {
+    return startMetaStore(HadoopThriftAuthBridge.getBridge(), conf);
+  }
+
+
+  public static void startMetaStore(final int port, final HadoopThriftAuthBridge bridge) throws Exception {
+    MetaStoreTestUtils.startMetaStore(port, bridge, null);
+  }
+
   public static void startMetaStore(final int port,
       final HadoopThriftAuthBridge bridge, Configuration conf)
       throws Exception{
@@ -63,14 +73,14 @@ public class MetaStoreTestUtils {
           LOG.error("Metastore Thrift Server threw an exception...", e);
         }
       }
-    }, "MetaStoreThread-" + port);
+    });
     thread.setDaemon(true);
     thread.start();
     MetaStoreTestUtils.loopUntilHMSReady(port);
   }
 
   public static int startMetaStoreWithRetry(final HadoopThriftAuthBridge bridge) throws Exception {
-    return MetaStoreTestUtils.startMetaStoreWithRetry(bridge, MetastoreConf.newMetastoreConf());
+    return MetaStoreTestUtils.startMetaStoreWithRetry(bridge, null);
   }
 
   public static int startMetaStoreWithRetry(Configuration conf) throws Exception {
@@ -78,34 +88,23 @@ public class MetaStoreTestUtils {
   }
 
   public static int startMetaStoreWithRetry() throws Exception {
-    return MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(),
-        MetastoreConf.newMetastoreConf());
+    return MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), null);
   }
 
-  /**
-   * 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
-   * fail if run parallel. Also adds the port to the warehouse dir, so the multiple MetaStore
-   * instances will use different warehouse directories.
-   * @param bridge The Thrift bridge to uses
-   * @param conf The configuration to use
-   * @return The port on which the MetaStore finally started
-   * @throws Exception
-   */
-  public static int startMetaStoreWithRetry(HadoopThriftAuthBridge bridge,
-                                            Configuration conf) throws Exception {
+  public static int startMetaStoreWithRetry(final HadoopThriftAuthBridge bridge, Configuration conf)
+      throws Exception {
+    int metaStorePort = findFreePort();
+    startMetaStoreWithRetry(metaStorePort, bridge, conf);
+    return metaStorePort;
+  }
+
+  private static void startMetaStoreWithRetry(int port, HadoopThriftAuthBridge bridge,
+                                             Configuration conf) 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();
-        Path postfixedWarehouseDir = new Path(warehouseDir, String.valueOf(metaStorePort));
-        MetastoreConf.setVar(conf, ConfVars.WAREHOUSE, postfixedWarehouseDir.toString());
-        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);
-        return metaStorePort;
+        MetaStoreTestUtils.startMetaStore(port, bridge, conf);
+        return;
       } catch (ConnectException ce) {
         metaStoreException = ce;
       }
@@ -117,7 +116,7 @@ public class MetaStoreTestUtils {
    * A simple connect test to make sure that the metastore is up
    * @throws Exception
    */
-  private static void loopUntilHMSReady(int port) throws Exception {
+  public static void loopUntilHMSReady(int port) throws Exception {
     int retries = 0;
     Exception exc = null;
     while (true) {
@@ -142,7 +141,7 @@ public class MetaStoreTestUtils {
     throw exc;
   }
 
-  private static String getAllThreadStacksAsString() {
+  public static String getAllThreadStacksAsString() {
     Map<Thread, StackTraceElement[]> threadStacks = Thread.getAllStackTraces();
     StringBuilder sb = new StringBuilder();
     for (Map.Entry<Thread, StackTraceElement[]> entry : threadStacks.entrySet()) {
@@ -154,7 +153,7 @@ public class MetaStoreTestUtils {
     return sb.toString();
   }
 
-  private static void addStackString(StackTraceElement[] stackElems, StringBuilder sb) {
+  public static void addStackString(StackTraceElement[] stackElems, StringBuilder sb) {
     sb.append(System.lineSeparator());
     for (StackTraceElement stackElem : stackElems) {
       sb.append(stackElem).append(System.lineSeparator());

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java
index ea5dd3c..13ed743 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java
@@ -151,7 +151,8 @@ public class TestFilterHooks {
     MetastoreConf.setClass(conf, ConfVars.FILTER_HOOK, DummyMetaStoreFilterHookImpl.class,
         MetaStoreFilterHook.class);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
 
     msc = new HiveMetaStoreClient(conf);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStorePartitionSpecs.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStorePartitionSpecs.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStorePartitionSpecs.java
index b2d1d5a..0a97b27 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStorePartitionSpecs.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStorePartitionSpecs.java
@@ -70,7 +70,7 @@ public class TestHiveMetaStorePartitionSpecs {
     MetastoreConf.setClass(metastoreConf, ConfVars.EXPRESSION_PROXY_CLASS,
       MockPartitionExpressionForMetastore.class, PartitionExpressionProxy.class);
     MetaStoreTestUtils.setConfForStandloneMode(metastoreConf);
-    msPort = MetaStoreTestUtils.startMetaStoreWithRetry(metastoreConf);
+    msPort = MetaStoreTestUtils.startMetaStore(metastoreConf);
     conf = MetastoreConf.newMetastoreConf();
     MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + msPort);
     MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreWithEnvironmentContext.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreWithEnvironmentContext.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreWithEnvironmentContext.java
index d53a606..42e77a6 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreWithEnvironmentContext.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStoreWithEnvironmentContext.java
@@ -75,7 +75,8 @@ public class TestHiveMetaStoreWithEnvironmentContext {
     MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);
     MetastoreConf.setBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
     msc = new HiveMetaStoreClient(conf);
 
     msc.dropDatabase(dbName, true, true);

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMarkPartitionRemote.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMarkPartitionRemote.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMarkPartitionRemote.java
index df474e6..55f3324 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMarkPartitionRemote.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMarkPartitionRemote.java
@@ -19,6 +19,8 @@
 package org.apache.hadoop.hive.metastore;
 
 import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
 import org.apache.hadoop.hive.metastore.security.HadoopThriftAuthBridge;
 import org.junit.Before;
 import org.junit.experimental.categories.Category;
@@ -28,7 +30,10 @@ public class TestMarkPartitionRemote extends TestMarkPartition {
 
   @Before
   public void startServer() throws Exception {
+    int port = MetaStoreTestUtils.findFreePort();
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
+    MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetaStoreTestUtils.startMetaStore(port, HadoopThriftAuthBridge.getBridge(), conf);
   }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEndFunctionListener.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEndFunctionListener.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEndFunctionListener.java
index 1a720fb..bfc819e 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEndFunctionListener.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEndFunctionListener.java
@@ -57,7 +57,8 @@ public class TestMetaStoreEndFunctionListener {
     MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);
     MetastoreConf.setBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
     msc = new HiveMetaStoreClient(conf);
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java
index fb7f940..2a0b5b6 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java
@@ -102,7 +102,8 @@ public class TestMetaStoreEventListener {
     MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);
     MetastoreConf.setBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
 
     msc = new HiveMetaStoreClient(conf);
 

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerOnlyOnCommit.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerOnlyOnCommit.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerOnlyOnCommit.java
index a91d1c8..062520b 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerOnlyOnCommit.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerOnlyOnCommit.java
@@ -63,7 +63,8 @@ public class TestMetaStoreEventListenerOnlyOnCommit {
     MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);
     MetastoreConf.setBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
     msc = new HiveMetaStoreClient(conf);
 
     DummyListener.notifyList.clear();

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerWithOldConf.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerWithOldConf.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerWithOldConf.java
index 0d18db6..508b2c6 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerWithOldConf.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListenerWithOldConf.java
@@ -49,13 +49,15 @@ public class TestMetaStoreEventListenerWithOldConf {
     System.setProperty("hive.metastore.pre.event.listeners",
         DummyPreListener.class.getName());
 
+    int port = MetaStoreTestUtils.findFreePort();
     conf = MetastoreConf.newMetastoreConf();
 
     MetastoreConf.setVar(conf, ConfVars.PARTITION_NAME_WHITELIST_PATTERN, metaConfVal);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
     MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);
     MetastoreConf.setBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetaStoreTestUtils.startMetaStore(port, HadoopThriftAuthBridge.getBridge(), conf);
 
     DummyListener.notifyList.clear();
     DummyPreListener.notifyList.clear();

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreInitListener.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreInitListener.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreInitListener.java
index b78076b..fd8fde4 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreInitListener.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreInitListener.java
@@ -43,7 +43,8 @@ public class TestMetaStoreInitListener {
     MetastoreConf.setLongVar(conf, ConfVars.THRIFT_CONNECTION_RETRIES, 3);
     MetastoreConf.setBoolVar(conf, ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreIpAddress.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreIpAddress.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreIpAddress.java
index 6b7d913..e26a97d 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreIpAddress.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreIpAddress.java
@@ -50,7 +50,9 @@ public class TestRemoteHiveMetaStoreIpAddress {
 
     System.setProperty(ConfVars.EVENT_LISTENERS.toString(), IpAddressListener.class.getName());
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    LOG.debug("Starting MetaStore Server on port " + port);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
 
     msc = new HiveMetaStoreClient(conf);
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRetryingHMSHandler.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRetryingHMSHandler.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRetryingHMSHandler.java
index 11f84f2..b72cc09 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRetryingHMSHandler.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestRetryingHMSHandler.java
@@ -52,7 +52,8 @@ public class TestRetryingHMSHandler {
     MetastoreConf.setTimeVar(conf, ConfVars.HMSHANDLERINTERVAL, 0, TimeUnit.MILLISECONDS);
     MetastoreConf.setBoolVar(conf, ConfVars.HMSHANDLERFORCERELOADCONF, false);
     MetaStoreTestUtils.setConfForStandloneMode(conf);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf);
+    MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + port);
     msc = new HiveMetaStoreClient(conf);
   }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
index 747f66d..7f854ed 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestAlterPartitions.java
@@ -160,8 +160,8 @@ public class TestAlterPartitions extends MetaStoreClientTest {
     partition.getSd().getCols().add(new FieldSchema("newcol", "string", ""));
   }
 
-  private void assertPartitionUnchanged(Partition partition, List<String> testValues,
-                                               List<String> partCols) throws MetaException {
+  private static void assertPartitionUnchanged(Partition partition, List<String> testValues,
+                                               List<String> partCols) {
     assertFalse(partition.getParameters().containsKey("hmsTestParam001"));
 
     List<String> expectedKVPairs = new ArrayList<>();
@@ -169,15 +169,15 @@ public class TestAlterPartitions extends MetaStoreClientTest {
       expectedKVPairs.add(partCols.get(i) + "=" + testValues.get(i));
     }
     String partPath = expectedKVPairs.stream().collect(joining("/"));
-    assertTrue(partition.getSd().getLocation().equals(metaStore.getWarehouseRoot()
-        + "/testpartdb.db/testparttable/" + partPath));
+    assertTrue(partition.getSd().getLocation().endsWith("warehouse/testpartdb" +
+            ".db/testparttable/" + partPath));
     assertNotEquals(NEW_CREATE_TIME, partition.getCreateTime());
     assertNotEquals(NEW_CREATE_TIME, partition.getLastAccessTime());
     assertEquals(2, partition.getSd().getCols().size());
   }
 
-  private void assertPartitionChanged(Partition partition, List<String> testValues,
-                                      List<String> partCols) throws MetaException {
+  private static void assertPartitionChanged(Partition partition, List<String> testValues,
+                                             List<String> partCols) {
     assertEquals("testValue001", partition.getParameters().get("hmsTestParam001"));
 
     List<String> expectedKVPairs = new ArrayList<>();
@@ -185,8 +185,8 @@ public class TestAlterPartitions extends MetaStoreClientTest {
       expectedKVPairs.add(partCols.get(i) + "=" + testValues.get(i));
     }
     String partPath = expectedKVPairs.stream().collect(joining("/"));
-    assertTrue(partition.getSd().getLocation().equals(metaStore.getWarehouseRoot()
-        + "/testpartdb.db/testparttable/" + partPath + "/hh=01"));
+    assertTrue(partition.getSd().getLocation().endsWith("warehouse/testpartdb" +
+            ".db/testparttable/" + partPath + "/hh=01"));
     assertEquals(NEW_CREATE_TIME, partition.getCreateTime());
     assertEquals(NEW_CREATE_TIME, partition.getLastAccessTime());
     assertEquals(3, partition.getSd().getCols().size());

http://git-wip-us.apache.org/repos/asf/hive/blob/f60aec0a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java
index b32d761..4249991 100644
--- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java
+++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java
@@ -36,8 +36,10 @@ public class RemoteMetaStoreForTests extends AbstractMetaStoreService {
 
   public void start() throws Exception {
     MetastoreConf.setBoolVar(getConfiguration(), MetastoreConf.ConfVars.EXECUTE_SET_UGI, false);
-    MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(),
+    int port = MetaStoreTestUtils.startMetaStore(HadoopThriftAuthBridge.getBridge(),
         getConfiguration());
+    MetastoreConf.setVar(getConfiguration(), MetastoreConf.ConfVars.THRIFT_URIS,
+        "thrift://localhost:" + port);
     super.start();
   }
 }