@Test
  public void testCustomWarehouseLocationsConf() throws Throwable {
    List<String> withClauseOptions = getStagingLocationConfig(primary.repldDir, false);
    String dbWhManagedLoc = new Path(primary.warehouseRoot.getParent(), "customManagedLoc1").toUri().getPath();
    String dbWhExternalLoc = new Path(primary.externalTableWarehouseRoot.getParent(),
            "customExternalLoc1").toUri().getPath();
    String srcDb = "srcDbConf";
    WarehouseInstance.Tuple tuple = primary
            .run("create database " + srcDb + " LOCATION '" + dbWhExternalLoc + "' MANAGEDLOCATION '" + dbWhManagedLoc
                    + "' WITH DBPROPERTIES ( '" + SOURCE_OF_REPLICATION + "' = '1,2,3')")
            .run("use " + srcDb)
            .run("create table t1 (id int)")
            .run("insert into table t1 values (500)")
            .run("create external table t2 (id int)")
            .run("insert into table t2 values (1000)")
            .dump(srcDb, withClauseOptions);

    withClauseOptions.add("'" + HiveConf.ConfVars.REPL_RETAIN_CUSTOM_LOCATIONS_FOR_DB_ON_TARGET.varname + "'='false'");
    replica.load(replicatedDbName, srcDb, 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("1000");
    List<String> listOfTables = new ArrayList<>();
    listOfTables.addAll(Arrays.asList("t1", "t2"));
    verifyCustomDBLocations(srcDb, listOfTables, dbWhManagedLoc, dbWhExternalLoc, false);
    primary.run("use " + srcDb)
            .run("insert into table t1 values (1000)")
            .run("insert into table t2 values (2000)")
            .dump(srcDb, withClauseOptions);
    replica.load(replicatedDbName, srcDb, withClauseOptions)
            .run("use " + replicatedDbName)
            .run("show tables like 't1'")
            .verifyResult("t1")
            .run("select id from t1")
            .verifyResults(new String[]{"500", "1000"})
            .run("show tables like 't2'")
            .verifyResult("t2")
            .run("select id from t2")
            .verifyResults(new String[]{"1000", "2000"});
    primary.run("use " + srcDb)
            .run("insert into table t1 values (2000)")
            .run("insert into table t2 values (3000)")
            .run("create table t3 (id int)")
            .run("insert into table t3 values (3000)")
            .run("create external table t4 (id int)")
            .run("insert into table t4 values (4000)")
            .dump(srcDb, withClauseOptions);
    replica.load(replicatedDbName, srcDb, withClauseOptions)
            .run("use " + replicatedDbName)
            .run("show tables like 't1'")
            .verifyResult("t1")
            .run("select id from t1")
            .verifyResults(new String[]{"500", "1000", "2000"})
            .run("show tables like 't2'")
            .verifyResult("t2")
            .run("select id from t2")
            .verifyResults(new String[]{"1000", "2000", "3000"})
            .run("show tables like 't3'")
            .verifyResult("t3")
            .run("select id from t3")
            .verifyResults(new String[]{"3000"})
            .run("show tables like 't4'")
            .verifyResult("t4")
            .run("select id from t4")
            .verifyResults(new String[]{"4000"});
    listOfTables.addAll(Arrays.asList("t3", "t4"));
    verifyCustomDBLocations(srcDb, listOfTables, dbWhManagedLoc, dbWhExternalLoc, false);
  }
Test replication scenarios with staging on replica.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosExclusiveReplica.java