@Test
  public void testRestoreEnabledSnapshot() throws IOException, InterruptedException {
    long tid = EnvironmentEdgeManager.currentTime();
    TableName tableName = TableName.valueOf("testtb-" + tid);
    String emptySnapshot = "emptySnaptb-" + tid;
    String snapshotName0 = "snaptb0-" + tid;
    String snapshotName1 = "snaptb1-" + tid;
    int snapshot0Rows;
    int snapshot1Rows;

    // create Table
    SnapshotTestingUtils.createTable(UTIL, tableName, getNumReplicas(), TEST_FAM);

    // take an empty snapshot
    takeSnapshot(tableName, emptySnapshot, false);

    // Insert data
    SnapshotTestingUtils.loadData(UTIL, tableName, 500, TEST_FAM);
    try (Table table = UTIL.getConnection().getTable(tableName)) {
      snapshot0Rows = UTIL.countRows(table);
    }

    // take a snapshot
    takeSnapshot(tableName, snapshotName0, false);

    // Insert more data
    SnapshotTestingUtils.loadData(UTIL, tableName, 500, TEST_FAM);
    try (Table table = UTIL.getConnection().getTable(tableName)) {
      snapshot1Rows = UTIL.countRows(table);
    }

    SnapshotTestingUtils.verifyRowCount(UTIL, tableName, snapshot1Rows);
    takeSnapshot(tableName, snapshotName1, false);

    // Restore from snapshot-0
    admin.disableTable(tableName);
    admin.restoreSnapshot(snapshotName0);
    admin.enableTable(tableName);
    SnapshotTestingUtils.verifyRowCount(UTIL, tableName, snapshot0Rows);
    SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());

    // Restore from emptySnapshot
    admin.disableTable(tableName);
    admin.restoreSnapshot(emptySnapshot);
    admin.enableTable(tableName);
    SnapshotTestingUtils.verifyRowCount(UTIL, tableName, 0);
    SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());

    // Restore from snapshot-1
    admin.disableTable(tableName);
    admin.restoreSnapshot(snapshotName1);
    admin.enableTable(tableName);
    SnapshotTestingUtils.verifyRowCount(UTIL, tableName, snapshot1Rows);
    SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());

    // Restore from snapshot-1
    UTIL.deleteTable(tableName);
    admin.restoreSnapshot(snapshotName1);
    SnapshotTestingUtils.verifyRowCount(UTIL, tableName, snapshot1Rows);
    SnapshotTestingUtils.verifyReplicasCameOnline(tableName, admin, getNumReplicas());
  }
Setup the config for the cluster
@throws Exception on failure
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotTemporaryDirectory.java