@Test
  public void testRegularCopyWithLocalStagingAndCopyTaskOnTarget() throws Throwable {
    List<String> withClauseOptions = getStagingLocationConfig(primary.repldDir, false);
    WarehouseInstance.Tuple tuple = primary
            .run("use " + primaryDbName)
            .run("create external table t1 (id int)")
            .run("insert into table t1 values (500)")
            .run("create table t2 (id int)")
            .run("insert into table t2 values (600)")
            .dump(primaryDbName, withClauseOptions);

    // verify that the external table list is written correctly for bootstrap
    ReplicationTestUtils.assertExternalFileList(Arrays.asList("t1"), tuple.dumpLocation, primary);

    replica.load(replicatedDbName, primaryDbName, withClauseOptions)
            .run("use " + replicatedDbName)
            .run("show tables like 't1'")
            .verifyResult("t1")
            .run("select id from t1")
            .verifyResult("500")
            .run("show tables like 't2'")
            .verifyResult("t2")
            .run("select id from t2")
            .verifyResult("600");

    tuple = primary.run("use " + primaryDbName)
            .run("create external table t3 (id int)")
            .run("insert into table t3 values (700)")
            .run("create table t4 (id int)")
            .run("insert into table t4 values (800)")
            .dump(primaryDbName, withClauseOptions);

    // verify that the external table list is written correctly for incremental
    ReplicationTestUtils.assertExternalFileList(Arrays.asList("t1", "t3"), tuple.dumpLocation, primary);

    replica.load(replicatedDbName, primaryDbName, withClauseOptions)
            .run("use " + replicatedDbName)
            .run("show tables like 't1'")
            .verifyResult("t1")
            .run("show tables like 't2'")
            .verifyResult("t2")
            .run("show tables like 't3'")
            .verifyResult("t3")
            .run("show tables like 't4'")
            .verifyResult("t4")
            .run("select id from t1")
            .verifyResult("500")
            .run("select id from t2")
            .verifyResult("600")
            .run("select id from t3")
            .verifyResult("700")
            .run("select id from t4")
            .verifyResult("800");
  }
Test replication scenarios with staging on replica.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExclusiveReplica.java