@Test
  public void testRegionServerLogTimestampMap() throws IOException {
    TreeSet<TableName> tables = new TreeSet<>();

    tables.add(TableName.valueOf("t1"));
    tables.add(TableName.valueOf("t2"));
    tables.add(TableName.valueOf("t3"));

    HashMap<String, Long> rsTimestampMap = new HashMap<>();

    rsTimestampMap.put("rs1:100", 100L);
    rsTimestampMap.put("rs2:100", 101L);
    rsTimestampMap.put("rs3:100", 103L);

    // validate the prefix scan in readLogTimestampMap will get the right timestamps
    // when a backup root with the same prefix is present
    table.writeRegionServerLogTimestamp(tables, rsTimestampMap, "root");
    table.writeRegionServerLogTimestamp(tables, rsTimestampMap, "root/backup");

    Map<TableName, Map<String, Long>> result = table.readLogTimestampMap("root");

    assertTrue(tables.size() == result.size());

    for (TableName t : tables) {
      Map<String, Long> rstm = result.get(t);
      assertNotNull(rstm);
      assertEquals(rstm.get("rs1:100"), Long.valueOf(100L));
      assertEquals(rstm.get("rs2:100"), Long.valueOf(101L));
      assertEquals(rstm.get("rs3:100"), Long.valueOf(103L));
    }

    Set<TableName> tables1 = new TreeSet<>();

    tables1.add(TableName.valueOf("t3"));
    tables1.add(TableName.valueOf("t4"));
    tables1.add(TableName.valueOf("t5"));

    HashMap<String, Long> rsTimestampMap1 = new HashMap<>();

    rsTimestampMap1.put("rs1:100", 200L);
    rsTimestampMap1.put("rs2:100", 201L);
    rsTimestampMap1.put("rs3:100", 203L);

    // validate the prefix scan in readLogTimestampMap will get the right timestamps
    // when a backup root with the same prefix is present
    table.writeRegionServerLogTimestamp(tables1, rsTimestampMap1, "root");
    table.writeRegionServerLogTimestamp(tables1, rsTimestampMap, "root/backup");

    result = table.readLogTimestampMap("root");

    assertTrue(5 == result.size());

    for (TableName t : tables) {
      Map<String, Long> rstm = result.get(t);
      assertNotNull(rstm);
      if (t.equals(TableName.valueOf("t3")) == false) {
        assertEquals(rstm.get("rs1:100"), Long.valueOf(100L));
        assertEquals(rstm.get("rs2:100"), Long.valueOf(101L));
        assertEquals(rstm.get("rs3:100"), Long.valueOf(103L));
      } else {
        assertEquals(rstm.get("rs1:100"), Long.valueOf(200L));
        assertEquals(rstm.get("rs2:100"), Long.valueOf(201L));
        assertEquals(rstm.get("rs3:100"), Long.valueOf(203L));
      }
    }

    for (TableName t : tables1) {
      Map<String, Long> rstm = result.get(t);
      assertNotNull(rstm);
      assertEquals(rstm.get("rs1:100"), Long.valueOf(200L));
      assertEquals(rstm.get("rs2:100"), Long.valueOf(201L));
      assertEquals(rstm.get("rs3:100"), Long.valueOf(203L));
    }

    cleanBackupTable();

  }
Test cases for backup system table API
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupSystemTable.java