diff --git itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProviderWithACL.java itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProviderWithACL.java index c2f7d6627e..61d2e920be 100644 --- itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProviderWithACL.java +++ itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationProviderWithACL.java @@ -49,6 +49,7 @@ protected static MiniDFSShim dfs = null; protected static Path warehouseDir = null; + protected static Path extWarehouseDir = null; protected UserGroupInformation userUgi = null; protected String testUserName = "test_user"; protected String proxyUserName = null; @@ -91,6 +92,9 @@ protected HiveConf createHiveConf() throws Exception { warehouseDir = new Path(new Path(fs.getUri()), "/warehouse"); fs.mkdirs(warehouseDir); conf.setVar(HiveConf.ConfVars.METASTOREWAREHOUSE, warehouseDir.toString()); + extWarehouseDir = new Path(new Path(fs.getUri()), "/external"); + fs.mkdirs(extWarehouseDir); + conf.setVar(HiveConf.ConfVars.HIVE_METASTORE_WAREHOUSE_EXTERNAL, extWarehouseDir.toString()); // Set up scratch directory Path scratchDir = new Path(new Path(fs.getUri()), "/scratchdir"); @@ -186,12 +190,14 @@ protected boolean mayTestLocation() { protected void allowCreateDatabase(String userName) throws Exception { allowWriteAccessViaAcl(userName, warehouseDir.toString()); + allowWriteAccessViaAcl(userName, extWarehouseDir.toString()); } @Override protected void disallowCreateDatabase(String userName) throws Exception { disallowWriteAccessViaAcl(userName, warehouseDir.toString()); + disallowWriteAccessViaAcl(userName, extWarehouseDir.toString()); } @Override diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java index bbc6ae4ef7..7e54dde6f9 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDDLWithRemoteMetastoreSecondNamenode.java @@ -222,7 +222,7 @@ private Table createTableAndCheck(String tableName, String tableLocation) } private Table createTableAndCheck(Table baseTable, String tableName, String tableLocation) throws Exception { - executeQuery("CREATE TABLE " + tableName + (baseTable == null ? + executeQuery("CREATE EXTERNAL TABLE " + tableName + (baseTable == null ? " (col1 string, col2 string) PARTITIONED BY (p string) " : " LIKE " + baseTable.getTableName()) + buildLocationClause(tableLocation)); diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestWarehouseExternalDir.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestWarehouseExternalDir.java index 120ab53f54..e87daf8983 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestWarehouseExternalDir.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestWarehouseExternalDir.java @@ -166,7 +166,7 @@ public void testManagedPaths() throws Exception { stmt.execute("create table twed_db1.tab1(c1 string, c2 string)"); tab = db.getTable("twed_db1", "tab1"); - checkTableLocation(tab, new Path(new Path(whRootExternalPath, "twed_db1.db"), "tab1")); + checkTableLocation(tab, new Path(new Path(whRootManagedPath, "twed_db1.db"), "tab1")); } } diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/BaseReplicationAcrossInstances.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/BaseReplicationAcrossInstances.java index b805b1915c..e629fe11e8 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/BaseReplicationAcrossInstances.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/BaseReplicationAcrossInstances.java @@ -50,6 +50,7 @@ static void internalBeforeClassSetup(Map overrides, Class clazz) conf = new HiveConf(clazz); conf.set("dfs.client.use.datanode.hostname", "true"); conf.set("hadoop.proxyuser." + Utils.getUGI().getShortUserName() + ".hosts", "*"); + conf.set("hive.repl.cmrootdir", "/tmp/"); MiniDFSCluster miniDFSCluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).format(true).build(); Map localOverrides = new HashMap() {{ @@ -72,7 +73,9 @@ public static void classLevelTearDown() throws IOException { public void setup() throws Throwable { primaryDbName = testName.getMethodName() + "_" + +System.currentTimeMillis(); replicatedDbName = "replicated_" + primaryDbName; - primary.run("create database " + primaryDbName + " WITH DBPROPERTIES ( '" + + String mgdLocation = "/tmp/warehouse/managed/" + primaryDbName; + String extLocation = "/tmp/warehouse/external/" + primaryDbName; + primary.run("create database " + primaryDbName + " LOCATION '" + extLocation + "' MANAGEDLOCATION '" + mgdLocation + "' WITH DBPROPERTIES ( '" + SOURCE_OF_REPLICATION + "' = '1,2,3')"); } diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java index fa96b87417..836a4c234f 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenarios.java @@ -176,6 +176,7 @@ static void internalBeforeClassSetup(Map additionalProperties, b "org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager"); hconf.set(HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL.varname, "org.apache.hadoop.hive.metastore.InjectableBehaviourObjectStore"); + hconf.set(HiveConf.ConfVars.HIVE_METASTORE_WAREHOUSE_EXTERNAL.varname, "/tmp/warehouse/external"); hconf.setBoolVar(HiveConf.ConfVars.HIVEOPTIMIZEMETADATAQUERIES, true); hconf.setBoolVar(HiveConf.ConfVars.HIVESTATSAUTOGATHER, true); hconf.setBoolVar(HiveConf.ConfVars.HIVE_STATS_RELIABLE, true); @@ -188,7 +189,8 @@ static void internalBeforeClassSetup(Map additionalProperties, b MetaStoreTestUtils.startMetaStoreWithRetry(hconf); // re set the WAREHOUSE property to the test dir, as the previous command added a random port to it - hconf.set(MetastoreConf.ConfVars.WAREHOUSE.getVarname(), System.getProperty("test.warehouse.dir", "/tmp")); + hconf.set(MetastoreConf.ConfVars.WAREHOUSE.getVarname(), System.getProperty("test.warehouse.dir", "/tmp/warehouse/managed")); + hconf.set(MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL.getVarname(), System.getProperty("test.warehouse.external.dir", "/tmp/warehouse/external")); Path testPath = new Path(TEST_PATH); FileSystem fs = FileSystem.get(testPath.toUri(),hconf); @@ -3441,8 +3443,16 @@ public void testDumpWithTableDirMissing() throws IOException { run("CREATE TABLE " + dbName + ".normal(a int)", driver); run("INSERT INTO " + dbName + ".normal values (1)", driver); - Path path = new Path(System.getProperty("test.warehouse.dir", "/tmp")); - path = new Path(path, dbName.toLowerCase() + ".db"); + Database db = null; + Path path = null; + + try { + metaStoreClient.getDatabase(dbName); + path = new Path(db.getManagedLocationUri()); + } catch (Exception e) { + path = new Path(System.getProperty("test.warehouse.dir", "/tmp/warehouse/managed")); + path = new Path(path, dbName.toLowerCase()+".db"); + } path = new Path(path, "normal"); FileSystem fs = path.getFileSystem(hconf); fs.delete(path); @@ -3465,8 +3475,16 @@ public void testDumpWithPartitionDirMissing() throws IOException { run("CREATE TABLE " + dbName + ".normal(a int) PARTITIONED BY (part int)", driver); run("INSERT INTO " + dbName + ".normal partition (part= 124) values (1)", driver); - Path path = new Path(System.getProperty("test.warehouse.dir", "/tmp")); - path = new Path(path, dbName.toLowerCase()+".db"); + Database db = null; + Path path = null; + + try { + metaStoreClient.getDatabase(dbName); + path = new Path(db.getManagedLocationUri()); + } catch (Exception e) { + path = new Path(System.getProperty("test.warehouse.dir", "/tmp/warehouse/managed")); + path = new Path(path, dbName.toLowerCase()+".db"); + } path = new Path(path, "normal"); path = new Path(path, "part=124"); FileSystem fs = path.getFileSystem(hconf); @@ -3626,7 +3644,9 @@ public void testMoveOptimizationIncremental() throws IOException { private static String createDB(String name, IDriver myDriver) { LOG.info("Testing " + name); - run("CREATE DATABASE " + name + " WITH DBPROPERTIES ( '" + + String mgdLocation = System.getProperty("test.warehouse.dir", "file:/tmp/warehouse/managed"); + String extLocation = System.getProperty("test.warehouse.external.dir", "/tmp/warehouse/external"); + run("CREATE DATABASE " + name + " LOCATION '" + extLocation + "/" + name.toLowerCase() + ".db' MANAGEDLOCATION '" + mgdLocation + "/" + name.toLowerCase() + ".db' WITH DBPROPERTIES ( '" + SOURCE_OF_REPLICATION + "' = '1,2,3')", myDriver); return name; } diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java index fd61cd8d27..213048624f 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java @@ -174,10 +174,12 @@ public void testSimplePrivileges() throws Exception { String dbName = getTestDbName(); String tblName = getTestTableName(); String userName = setupUser(); + String loc = clientHiveConf.get(HiveConf.ConfVars.HIVE_METASTORE_WAREHOUSE_EXTERNAL.varname) + "/" + dbName; + String mLoc = clientHiveConf.get(HiveConf.ConfVars.METASTOREWAREHOUSE.varname) + "/" + dbName; allowCreateDatabase(userName); - driver.run("create database " + dbName); + driver.run("create database " + dbName + " location '" + loc + "' managedlocation '" + mLoc + "'"); Database db = msc.getDatabase(dbName); - String dbLocn = db.getLocationUri(); + String dbLocn = db.getManagedLocationUri(); validateCreateDb(db, dbName); allowCreateInDb(dbName, userName, dbLocn); disallowCreateInDb(dbName, userName, dbLocn); @@ -328,6 +330,8 @@ public void testSimplePrivileges() throws Exception { InjectableDummyAuthenticator.injectMode(true); allowCreateDatabase(userName); driver.run("create database " + dbName); + db = msc.getDatabase(dbName); + dbLocn = db.getLocationUri(); allowCreateInDb(dbName, userName, dbLocn); tbl.setTableType("EXTERNAL_TABLE"); msc.createTable(tbl); diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java index 7092ee869a..1d816dbd33 100755 --- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java +++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java @@ -293,7 +293,7 @@ private boolean hasExternalWarehouseRoot() { @Deprecated public Path getDefaultTablePath(Database db, String tableName) throws MetaException { - return getDefaultTablePath(db, tableName, false); + return getDefaultTablePath(db, tableName, true); } public Path getDefaultTablePath(Database db, String tableName, boolean isExternal) throws MetaException { @@ -305,11 +305,7 @@ public Path getDefaultTablePath(Database db, String tableName, boolean isExterna dbPath = getDefaultExternalDatabasePath(db.getName()); } } else { - if (isTenantBasedStorage) { - dbPath = getDatabaseManagedPath(db); - } else { - dbPath = getDatabasePath(db); - } + dbPath = getDatabaseManagedPath(db); } return getDnsPath( new Path(dbPath, MetaStoreUtils.encodeTableName(tableName.toLowerCase()))); diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 77d34047a4..1a88eb2eb0 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -35,6 +35,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; +import java.lang.reflect.UndeclaredThrowableException; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; @@ -1408,8 +1409,32 @@ private void create_database_core(RawStore ms, final Database db) LOG.error("No such catalog " + db.getCatalogName()); throw new InvalidObjectException("No such catalog " + db.getCatalogName()); } - Path dbPath = wh.determineDatabasePath(cat, db); - db.setLocationUri(dbPath.toString()); + boolean skipAuthorization = false; + String passedInURI = db.getLocationUri(); + String passedInManagedURI = db.getManagedLocationUri(); + if (passedInURI == null && passedInManagedURI == null) { + skipAuthorization = true; + } + final Path defaultDbExtPath = wh.getDefaultDatabasePath(db.getName(), true); + final Path defaultDbMgdPath = wh.getDefaultDatabasePath(db.getName(), false); + final Path dbExtPath = (passedInURI != null) ? wh.getDnsPath(new Path(passedInURI)) : wh.determineDatabasePath(cat, db); + final Path dbMgdPath = (passedInManagedURI != null) ? wh.getDnsPath(new Path(passedInManagedURI)) : null; + + if ((defaultDbExtPath.equals(dbExtPath) && defaultDbMgdPath.equals(dbMgdPath)) && + ((dbMgdPath == null) || dbMgdPath.equals(defaultDbMgdPath))) { + skipAuthorization = true; + } + + if ( skipAuthorization ) { + //null out to skip authorizer URI check + db.setLocationUri(null); + db.setManagedLocationUri(null); + }else{ + db.setLocationUri(dbExtPath.toString()); + if (dbMgdPath != null) { + db.setManagedLocationUri(dbMgdPath.toString()); + } + } if (db.getOwnerName() == null){ try { db.setOwnerName(SecurityUtils.getUGI().getShortUserName()); @@ -1420,18 +1445,77 @@ private void create_database_core(RawStore ms, final Database db) long time = System.currentTimeMillis()/1000; db.setCreateTime((int) time); boolean success = false; - boolean madeDir = false; + boolean madeManagedDir = false; + boolean madeExternalDir = false; boolean isReplicated = isDbReplicationTarget(db); Map transactionalListenersResponses = Collections.emptyMap(); try { firePreEvent(new PreCreateDatabaseEvent(db, this)); - if (!wh.isDir(dbPath)) { - LOG.debug("Creating database path " + dbPath); - if (!wh.mkdirs(dbPath)) { - throw new MetaException("Unable to create database path " + dbPath + - ", failed to create database " + db.getName()); + //reinstate location uri for metastore db. + if (skipAuthorization == true){ + db.setLocationUri(dbExtPath.toString()); + if (dbMgdPath != null) + db.setManagedLocationUri(dbMgdPath.toString()); + } + if (db.getCatalogName() != null && !db.getCatalogName(). + equals(Warehouse.DEFAULT_CATALOG_NAME)) { + if (!wh.isDir(dbExtPath)) { + LOG.debug("Creating database path " + dbExtPath); + if (!wh.mkdirs(dbExtPath)) { + throw new MetaException("Unable to create database path " + dbExtPath + + ", failed to create database " + db.getName()); + } + madeExternalDir = true; + } + } else { + if (dbMgdPath != null) { + try { + // Since this may be done as random user (if doAs=true) he may not have access + // to the managed directory. We run this as an admin user + madeManagedDir = UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction() { + @Override public Boolean run() throws MetaException { + if (!wh.isDir(dbMgdPath)) { + LOG.info("Creating database path in managed directory " + dbMgdPath); + if (!wh.mkdirs(dbMgdPath)) { + throw new MetaException("Unable to create database managed path " + dbMgdPath + ", failed to create database " + db.getName()); + } + return true; + } + return false; + } + }); + if (madeManagedDir) { + LOG.info("Created database path in managed directory " + dbMgdPath); + } + } catch (IOException | InterruptedException e) { + throw new MetaException( + "Unable to create database managed directory " + dbMgdPath + ", failed to create database " + db.getName()); + } + } + if (dbExtPath != null) { + try { + madeExternalDir = UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction() { + @Override public Boolean run() throws MetaException { + if (!wh.isDir(dbExtPath)) { + LOG.info("Creating database path in external directory " + dbExtPath); + return wh.mkdirs(dbExtPath); + } + return false; + } + }); + if (madeExternalDir) { + LOG.info("Created database path in external directory " + dbExtPath); + } else { + LOG.warn("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the " + + "StorageBasedAuthorizationProvider is enabled "); + } + } catch (IOException | InterruptedException | UndeclaredThrowableException e) { + LOG.warn("Failed to create external path " + dbExtPath + " for database " + db.getName() + ". This may result in access not being allowed if the " + + "StorageBasedAuthorizationProvider is enabled: " + e.getMessage()); + } + } else { + LOG.info("Database external path won't be created since the external warehouse directory is not defined"); } - madeDir = true; } ms.openTransaction(); @@ -1448,8 +1532,40 @@ private void create_database_core(RawStore ms, final Database db) } finally { if (!success) { ms.rollbackTransaction(); - if (madeDir) { - wh.deleteDir(dbPath, true, db); + + if (db.getCatalogName() != null && !db.getCatalogName(). + equals(Warehouse.DEFAULT_CATALOG_NAME)) { + if (madeManagedDir) { + wh.deleteDir(dbMgdPath, true, db); + } + } else { + if (madeManagedDir) { + try { + UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction() { + @Override public Void run() throws Exception { + wh.deleteDir(dbMgdPath, true, db); + return null; + } + }); + } catch (IOException | InterruptedException e) { + LOG.error( + "Couldn't delete managed directory " + dbMgdPath + " after " + "it was created for database " + db.getName() + " " + e.getMessage()); + } + } + + if (madeExternalDir) { + try { + UserGroupInformation.getCurrentUser().doAs(new PrivilegedExceptionAction() { + @Override public Void run() throws Exception { + wh.deleteDir(dbExtPath, true, db); + return null; + } + }); + } catch (IOException | InterruptedException e) { + LOG.error("Couldn't delete external directory " + dbExtPath + " after " + "it was created for database " + + db.getName() + " " + e.getMessage()); + } + } } } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java index d1558876f1..e44ce7aaa2 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java @@ -375,7 +375,7 @@ public Database getDatabase(String catName, String dbName) throws MetaException{ String queryTextDbSelector= "select " + "\"DB_ID\", \"NAME\", \"DB_LOCATION_URI\", \"DESC\", " + "\"OWNER_NAME\", \"OWNER_TYPE\", \"CTLG_NAME\" , \"CREATE_TIME\", \"DB_MANAGED_LOCATION_URI\"" - + "FROM "+ DBS + + " FROM "+ DBS + " where \"NAME\" = ? and \"CTLG_NAME\" = ? "; Object[] params = new Object[] { dbName, catName }; queryDbSelector = pm.newQuery("javax.jdo.query.SQL", queryTextDbSelector); diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/NonCatCallsWithCatalog.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/NonCatCallsWithCatalog.java index b5e51ae8a3..fdfa9d4e96 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/NonCatCallsWithCatalog.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/NonCatCallsWithCatalog.java @@ -93,6 +93,7 @@ protected abstract IMetaStoreClient getClient() throws Exception; protected abstract String expectedCatalog(); protected abstract String expectedBaseDir() throws MetaException; + protected abstract String expectedExtBaseDir() throws MetaException; @Before public void setUp() throws Exception { @@ -218,7 +219,7 @@ public void databases() throws TException, URISyntaxException { } Database fetched = client.getDatabase(dbNames[0]); - String expectedLocation = new File(expectedBaseDir(), dbNames[0] + ".db").toURI().toString(); + String expectedLocation = new File(expectedExtBaseDir(), dbNames[0] + ".db").toURI().toString(); Assert.assertEquals(expectedCatalog(), fetched.getCatalogName()); Assert.assertEquals(expectedLocation, fetched.getLocationUri() + "/"); String db0Location = new URI(fetched.getLocationUri()).getPath(); diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultClient.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultClient.java index 550b107d3d..8c3bd7c592 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultClient.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultClient.java @@ -71,4 +71,9 @@ protected String expectedCatalog() { protected String expectedBaseDir() throws MetaException { return catLocation; } + + @Override + protected String expectedExtBaseDir() throws MetaException { + return catLocation; + } } diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultSvr.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultSvr.java index cf909ac299..3e96781872 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultSvr.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogNonDefaultSvr.java @@ -65,4 +65,9 @@ protected String expectedCatalog() { protected String expectedBaseDir() throws MetaException { return catLocation; } + + @Override + protected String expectedExtBaseDir() throws MetaException { + return catLocation; + } } diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogOldClient.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogOldClient.java index 642805ed17..b6f3fa71df 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogOldClient.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestCatalogOldClient.java @@ -39,6 +39,11 @@ protected String expectedCatalog() { @Override protected String expectedBaseDir() throws MetaException { + return new Warehouse(conf).getWhRoot().toUri().getPath(); + } + + @Override + protected String expectedExtBaseDir() throws MetaException { return new Warehouse(conf).getWhRootExternal().toUri().getPath(); } } diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java index 6d82d794ca..c063ad703a 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java @@ -348,7 +348,7 @@ public void testCreateTableDefaultLocationInSpecificDatabase() throws Exception client.createTable(table); Table createdTable = client.getTable(table.getDbName(), table.getTableName()); - Assert.assertEquals("Storage descriptor location", metaStore.getExternalWarehouseRoot() + Assert.assertEquals("Storage descriptor location", metaStore.getWarehouseRoot() + "/" + table.getDbName() + ".db/" + table.getTableName(), createdTable.getSd().getLocation()); }