public static void cleanupHMS(Hive hive, Warehouse wh, FsPermission defaultPerm)
    throws HiveException, MetaException, NoSuchObjectException {
    for (String dbName : hive.getAllDatabases()) {
      if (dbName.equals("default")) {
        continue;
      }
      try {
        Path path = getDbPath(hive, wh, dbName);
        FileSystem whFs = path.getFileSystem(hive.getConf());
        whFs.setPermission(path, defaultPerm);
      } catch (IOException ex) {
        //ignore
      }
      hive.dropDatabase(dbName, true, true, true);
    }

    //clean tables in default db
    for (String tablename : hive.getAllTables("default")) {
      hive.dropTable("default", tablename, true, true);
    }
  }
Removes all databases and tables from the metastore
hcatalog/core/src/test/java/org/apache/hive/hcatalog/HcatTestUtils.java