@Test
  public void testTableAndPartitionExportServiceWithParallelism() throws Throwable {
    List<String> extTableList = new ArrayList<String>();
    List<String> mgnTableList = new ArrayList<String>();
    List<String> dumpWithClause = ReplicationTestUtils.includeExternalTableClause(true);

    primary.run("use " + primaryDbName);

    // create 5 managed partitioned and 5 external un-partitioned tables.
    // create first 2 tables with  2 partitions, another 2 with 4 partitions and
    // another 2 tables with 6 partitions and so on.

    int pt = 0;
    for (int i = 0; i < 5; i++) {
      primary.run("CREATE EXTERNAL TABLE ptned" + i + " (a int)");
      extTableList.add("ptned" + i);
      primary.run("CREATE TABLE ptnmgned" + i + " (a int) partitioned by (b int)");
      mgnTableList.add("ptnmgned" + i);

      if (i % 2 == 0) {
        pt += 2;
      }
      for (int j = 0; j < pt; j++) {
        primary.run("ALTER TABLE ptnmgned" + i + " ADD PARTITION(b=" + j + ")");
        // insert some rows in each partitions of table
        for (int k = 0; k < pt; k++) {
          primary.run("INSERT INTO TABLE ptned" + i + " VALUES (" + k + ")");
          primary.run("INSERT INTO TABLE ptnmgned" + i + " PARTITION(b=" + j + ") VALUES (" + k + ")");
        }
      }
    }

    // create 5 un-partitioned table
    for (int i = 0; i < 5; i++) {
      primary.run("CREATE EXTERNAL TABLE unptned" + i + " (a int)");
      extTableList.add("unptned" + i);
      primary.run("CREATE TABLE unptnmgned" + i + " (a int)");
      mgnTableList.add("unptnmgned" + i);
      //insert some rows in each tables
      for (int j = 0; j < 2; j++) {
        primary.run("INSERT INTO TABLE unptned" + i + " VALUES (" + j + ")");
        primary.run("INSERT INTO TABLE unptnmgned" + i + " VALUES (" + j + ")");
      }
    }

    //start bootstrap dump
    WarehouseInstance.Tuple tuple = primary.dump(primaryDbName, dumpWithClause);
    // verify that the external table filelist is written correctly for bootstrap
    ReplicationTestUtils.assertExternalFileList(extTableList, tuple.dumpLocation, primary);

    List<String> newTableList = new ArrayList<String>();
    newTableList.addAll(extTableList);
    newTableList.addAll(mgnTableList);

    replica.load(replicatedDbName, primaryDbName, dumpWithClause)
        .run("use " + replicatedDbName)
        .run("show tables")
        .verifyResults(newTableList);

    primary.run("use " + primaryDbName);
    // create 5 un-partitioned table for incremental dump
    for (int i = 0; i < 5; i++) {
      primary.run("CREATE EXTERNAL TABLE incrunptned" + i + "(a int)");
      extTableList.add("incrunptned" + i);
      primary.run("CREATE TABLE incrunptnmgned" + i + "(a int)");
      mgnTableList.add("incrunptnmgned" + i);
      // insert some rows in each tables
      for (int j = 0; j < 2; j++) {
        primary.run("INSERT INTO TABLE incrunptned" + i + " VALUES (" + j + ")");
        primary.run("INSERT INTO TABLE incrunptnmgned" + i + " VALUES (" + j + ")");
      }
    }

    newTableList.clear();
    newTableList.addAll(extTableList);
    newTableList.addAll(mgnTableList);

    //start incremental dump
    WarehouseInstance.Tuple newTuple = primary.dump(primaryDbName, dumpWithClause);

    replica.load(replicatedDbName, primaryDbName, dumpWithClause)
        .run("use " + replicatedDbName)
        .run("show tables")
        .verifyResults(newTableList);

    // verify that the external table filelist is written correctly for incremental dump
    ReplicationTestUtils.assertExternalFileList(extTableList, newTuple.dumpLocation, primary);
  }
@param sourceTableName  -- Provide the fully qualified table name
@param replicaTableName -- Provide the fully qualified table name
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExternalTables.java