diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java index 1d12cf9..3bf61fe 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/MetaStoreTestUtils.java @@ -101,15 +101,33 @@ public static int startMetaStoreWithRetry(HadoopThriftAuthBridge bridge, Configuration conf) throws Exception { Exception metaStoreException = null; String warehouseDir = MetastoreConf.getVar(conf, ConfVars.WAREHOUSE); + String jdbcUrl = MetastoreConf.getVar(conf, ConfVars.CONNECT_URL_KEY); + 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()); + + // Setting metastore instance specific jdbc url postfixed with port + String postfixedJdbcUrl = jdbcUrl.replace("junit_metastore_db", "junit_metastore_db_" + + metaStorePort); + MetastoreConf.setVar(conf, ConfVars.CONNECT_URL_KEY, postfixedJdbcUrl); + + // 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())) { + wh.mkdirs(wh.getWhRoot()); + LOG.info("MetaStore warehouse root dir ({}) is created", postfixedWarehouseDir); + } + + LOG.info("MetaStore Thrift Server started on port: {} with warehouse dir: {} with " + + "jdbcUrl: {}", metaStorePort, postfixedWarehouseDir, postfixedJdbcUrl); return metaStorePort; } catch (ConnectException ce) { metaStoreException = ce;