@Test
  public void testBackupHistory() throws Exception {

    LOG.info("test backup history on a single table with data");

    List<TableName> tableList = Lists.newArrayList(table1);
    String backupId = fullTableBackup(tableList);
    assertTrue(checkSucceeded(backupId));
    LOG.info("backup complete");

    List<BackupInfo> history = getBackupAdmin().getHistory(10);
    assertTrue(findBackup(history, backupId));
    BackupInfo.Filter nullFilter = info -> true;
    history = BackupUtils.getHistory(conf1, 10, new Path(BACKUP_ROOT_DIR), nullFilter);
    assertTrue(findBackup(history, backupId));

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    System.setOut(new PrintStream(baos));

    String[] args = new String[] { "history", "-n", "10", "-p", BACKUP_ROOT_DIR };
    // Run backup
    int ret = ToolRunner.run(conf1, new BackupDriver(), args);
    assertTrue(ret == 0);
    LOG.info("show_history");
    String output = baos.toString();
    LOG.info(output);
    baos.close();
    assertTrue(output.indexOf(backupId) > 0);

    tableList = Lists.newArrayList(table2);
    String backupId2 = fullTableBackup(tableList);
    assertTrue(checkSucceeded(backupId2));
    LOG.info("backup complete: " + table2);
    BackupInfo.Filter tableNameFilter = image -> {
      if (table1 == null) {
        return true;
      }

      List<TableName> names = image.getTableNames();
      return names.contains(table1);
    };
    BackupInfo.Filter tableSetFilter = info -> {
      String backupId1 = info.getBackupId();
      return backupId1.startsWith("backup");
    };

    history = getBackupAdmin().getHistory(10, tableNameFilter, tableSetFilter);
    assertTrue(history.size() > 0);
    boolean success = true;
    for (BackupInfo info : history) {
      if (!info.getTableNames().contains(table1)) {
        success = false;
        break;
      }
    }
    assertTrue(success);

    history =
      BackupUtils.getHistory(conf1, 10, new Path(BACKUP_ROOT_DIR), tableNameFilter, tableSetFilter);
    assertTrue(history.size() > 0);
    success = true;
    for (BackupInfo info : history) {
      if (!info.getTableNames().contains(table1)) {
        success = false;
        break;
      }
    }
    assertTrue(success);

    args =
      new String[] { "history", "-n", "10", "-p", BACKUP_ROOT_DIR, "-t", "table1", "-s", "backup" };
    // Run backup
    ret = ToolRunner.run(conf1, new BackupDriver(), args);
    assertTrue(ret == 0);
    LOG.info("show_history");
  }
Verify that full backup is created on a single table with data correctly. Verify that history
works as expected.
@throws Exception if doing the backup or an operation on the tables fails
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupShowHistory.java