@Test
public void testExportRS1ImportRS2() throws Exception {

    ArrayList<ServerName> serverNameList;
    List<HRegionInfo> regionInfoList;
    ServerName rs1, rs2;
    String expFileName = "export_test.exp";
    splitTable("a".getBytes());
    splitTable("b".getBytes());
    serverNameList = getServerNameList();
    rs1 = serverNameList.get(0);
    rs2 = serverNameList.get(1);
    // move all regions to rs1 except 1
    regionInfoList = getRegionInfoList(tableName);
    for (HRegionInfo hRegionInfo : regionInfoList)
        move(hRegionInfo, rs1);
    HRegionInfo region1 = regionInfoList.get(0);
    HRegionInfo region2 = regionInfoList.get(1);
    HRegionInfo region3 = regionInfoList.get(2);
    move(region1, rs2);
    assertEquals(region1, getRegionInfoList(rs2, tableName).get(0));
    assertEquals(region2, getRegionInfoList(rs1, tableName).get(0));
    assertEquals(region3, getRegionInfoList(rs1, tableName).get(1));
    boolean balancerRunning = false;
    try {
        String[] argsParam;
        Args args;
        Assign command;
        balancerRunning = admin.setBalancerRunning(false, true);
        // export RS1
        argsParam = new String[]{"zookeeper", "export", expFileName, "--rs=" + rs1.getServerName()};
        args = new ManagerArgs(argsParam);
        command = new Assign(admin, args);
        command.run();
        // move regions
        move(region1, rs1);
        move(region2, rs2);
        move(region3, rs1);
        assertEquals(region1, getRegionInfoList(rs1, tableName).get(0));
        assertEquals(region2, getRegionInfoList(rs2, tableName).get(0));
        assertEquals(region3, getRegionInfoList(rs1, tableName).get(1));
        // import rs2
        argsParam = new String[]{"zookeeper", "import", expFileName,
            "--force-proceed", "--rs=" + rs2.getServerName()};
        args = new ManagerArgs(argsParam);
        command = new Assign(admin, args);
        command.run();
        // check
        assertEquals(region1, getRegionInfoList(rs1, tableName).get(0));
        assertEquals(region2, getRegionInfoList(rs2, tableName).get(0));
        assertEquals(region3, getRegionInfoList(rs1, tableName).get(1));
    } finally {
        if (balancerRunning)
            admin.setBalancerRunning(true, true);
        Files.delete(Paths.get(expFileName));
    }
}