@Test
  public void testSkipReplayAndUpdateSeqId() throws Exception {
    rootDir = TEST_UTIL.getDefaultRootDirPath();
    CommonFSUtils.setRootDir(conf, rootDir);
    TableName tableName = TableName.valueOf("testSkipReplayAndUpdateSeqId");
    String snapshotName = "testSkipReplayAndUpdateSeqId";
    createTableAndSnapshot(tableName, snapshotName);
    // put some data in the table
    Table table = TEST_UTIL.getConnection().getTable(tableName);
    TEST_UTIL.loadTable(table, Bytes.toBytes("A"));

    Configuration conf = TEST_UTIL.getConfiguration();
    Path rootDir = CommonFSUtils.getRootDir(conf);
    Path restoreDir = new Path("/hbase/.tmp-restore/testScannerWithRestoreScanner2");
    // restore snapshot.
    final RestoreSnapshotHelper.RestoreMetaChanges meta =
      RestoreSnapshotHelper.copySnapshotForScanner(conf, fs, rootDir, restoreDir, snapshotName);
    TableDescriptor htd = meta.getTableDescriptor();
    final List<RegionInfo> restoredRegions = meta.getRegionsToAdd();
    for (RegionInfo restoredRegion : restoredRegions) {
      // open restored region
      HRegion region = HRegion.newHRegion(CommonFSUtils.getTableDir(restoreDir, tableName), null,
        fs, conf, restoredRegion, htd, null);
      // set restore flag
      region.setRestoredRegion(true);
      region.initialize();
      Path recoveredEdit =
        CommonFSUtils.getWALRegionDir(conf, tableName, region.getRegionInfo().getEncodedName());
      long maxSeqId = WALSplitUtil.getMaxRegionSequenceId(fs, recoveredEdit);

      // open restored region without set restored flag
      HRegion region2 = HRegion.newHRegion(CommonFSUtils.getTableDir(restoreDir, tableName), null,
        fs, conf, restoredRegion, htd, null);
      region2.initialize();
      long maxSeqId2 = WALSplitUtil.getMaxRegionSequenceId(fs, recoveredEdit);
      Assert.assertTrue(maxSeqId2 > maxSeqId);
    }
  }
Test the restore/clone operation from a file-system point of view.
hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestRestoreSnapshotHelper.java