@Test
  public void testDiffExtTblLocs() throws Exception {
    String extTblLocation = getTestDataDir() + "/ext";
    String outLocation = getTestDataDir() + "/extTblOutput";
    Configuration conf = MetastoreConf.newMetastoreConf();
    MetastoreConf.setVar(conf, MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL, getWarehouseDir());
    MetaToolTaskListExtTblLocs.msConf = conf;

    //create first file using -listExtTblLocs
    runStatementOnDriver("create database diffDb");
    runStatementOnDriver("create external table diffDb.ext1(a int) partitioned by (p int)");
    runStatementOnDriver("create external table diffDb.ext2(a int) partitioned by (p int)");
    runStatementOnDriver("create external table diffDb.ext3(a int) partitioned by (p int) " +
            "location '" + getTestDataDir() + "/ext/tblLoc'");
    runStatementOnDriver("alter table diffDb.ext1 add partition(p = 0) location '" + getTestDataDir() + "/part'" );
    runStatementOnDriver("alter table diffDb.ext1 add partition(p = 1) location '" + getTestDataDir() + "/part'" );
    String outLocation1 = outLocation + "1";
    getListExtTblLocs("diffDb", outLocation1);

    //create second file using -listExtTblLocs after dropping a table, dropping a partition and adding a different partition
    runStatementOnDriver("drop table diffDb.ext2");
    runStatementOnDriver("alter table diffDb.ext1 drop partition(p = 0)" );
    runStatementOnDriver("alter table diffDb.ext1 add partition(p = 3) location '" + getTestDataDir() + "/part'" );
    String outLocation2 = outLocation + "2";
    getListExtTblLocs("diffDb", outLocation2);

    //run diff on the above two files
    JSONObject outJS = getDiffExtTblLocs(outLocation1, outLocation2, outLocation);
    Set<String> outLocationSet = outJS.keySet();
    String defaultDbLoc = getAbsolutePath(getWarehouseDir() + "/diffdb.db");
    Assert.assertEquals(outLocationSet.size(), 2);
    Assert.assertTrue(outLocationSet.contains(defaultDbLoc));
    JSONArray outArr = outJS.getJSONArray(defaultDbLoc);
    Assert.assertEquals(outArr.length(), 1);
    Assert.assertTrue(outArr.getString(0).equals("- diffdb.ext2")); // dropped ext2 from default location
    String partLoc = getAbsolutePath(getTestDataDir() + "/part");
    Assert.assertTrue(outLocationSet.contains(partLoc));
    outArr = outJS.getJSONArray(partLoc);
    Assert.assertEquals(outArr.length(), 2); //two entries - 1 for added partition and 1 for dropped partition
    Assert.assertTrue(outArr.getString(0).equals("+ diffdb.ext1.p=3"));
    Assert.assertTrue(outArr.getString(1).equals("- diffdb.ext1.p=0"));
  }
Integration tests for the HiveMetaTool program.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/tools/metatool/TestHiveMetaTool.java