@Override
  public int runTestFromCommandLine() throws Exception {
    Configuration conf = getConf();
    TableName tableName = TableName.valueOf(conf.get(TABLE_NAME_KEY, DEFAULT_TABLE_NAME));
    String snapshotName = conf.get(SNAPSHOT_NAME_KEY,
      tableName.getQualifierAsString() + "_snapshot_" + EnvironmentEdgeManager.currentTime());
    int numRegions = conf.getInt(NUM_REGIONS_KEY, DEFAULT_NUM_REGIONS);
    String tableDirStr = conf.get(TABLE_DIR_KEY);
    Path tableDir;
    if (tableDirStr == null) {
      tableDir = util.getDataTestDirOnTestFS(tableName.getQualifierAsString());
    } else {
      tableDir = new Path(tableDirStr);
    }

    final String mr = conf.get(MR_IMPLEMENTATION_KEY, MAPREDUCE_IMPLEMENTATION);
    if (mr.equalsIgnoreCase(MAPREDUCE_IMPLEMENTATION)) {
      /*
       * We create the table using HBaseAdmin#createTable(), which will create the table with
       * desired number of regions. We pass bbb as startKey and yyy as endKey, so if
       * desiredNumRegions is > 2, we create regions empty - bbb and yyy - empty, and we create
       * numRegions - 2 regions between bbb - yyy. The test uses a Scan with startRow bbb and endRow
       * yyy, so, we expect the first and last region to be filtered out in the input format, and we
       * expect numRegions - 2 splits between bbb and yyy.
       */
      LOG.debug("Running job with mapreduce API.");
      int expectedNumSplits = numRegions > 2 ? numRegions - 2 : numRegions;

      org.apache.hadoop.hbase.mapreduce.TestTableSnapshotInputFormat.doTestWithMapReduce(util,
        tableName, snapshotName, START_ROW, END_ROW, tableDir, numRegions, 1, expectedNumSplits,
        false);
    } else if (mr.equalsIgnoreCase(MAPRED_IMPLEMENTATION)) {
      /*
       * Similar considerations to above. The difference is that mapred API does not support
       * specifying start/end rows (or a scan object at all). Thus the omission of first and last
       * regions are not performed. See comments in mapred.TestTableSnapshotInputFormat for details
       * of how that test works around the problem. This feature should be added in follow-on work.
       */
      LOG.debug("Running job with mapred API.");
      int expectedNumSplits = numRegions;

      org.apache.hadoop.hbase.mapred.TestTableSnapshotInputFormat.doTestWithMapReduce(util,
        tableName, snapshotName, MAPRED_START_ROW, MAPRED_END_ROW, tableDir, numRegions, 1,
        expectedNumSplits, false);
    } else {
      throw new IllegalArgumentException("Unrecognized mapreduce implementation: " + mr + ".");
    }

    return 0;
  }
An integration test to test {@link TableSnapshotInputFormat} which enables reading directly from
snapshot files without going through hbase servers. This test creates a table and loads the table
with the rows ranging from 'aaa' to 'zzz', and for each row, sets the columns f1:(null) and
f2:(null) to be the the same as the row value.

<pre>
aaa, f1: =&gt; aaa
aaa, f2: =&gt; aaa
aab, f1: =&gt; aab
....
zzz, f2: =&gt; zzz
</pre>

Then the test creates a snapshot from this table, and overrides the values in the original table
with values 'after_snapshot_value'. The test, then runs a mapreduce job over the snapshot with a
scan start row 'bbb' and stop row 'yyy'. The data is saved in a single reduce output file, and
inspected later to verify that the MR job has seen all the values from the snapshot.
<p>
These parameters can be used to configure the job: <br>
"IntegrationTestTableSnapshotInputFormat.table" =&gt; the name of the table <br>
"IntegrationTestTableSnapshotInputFormat.snapshot" =&gt; the name of the snapshot <br>
"IntegrationTestTableSnapshotInputFormat.numRegions" =&gt; number of regions in the table to be
created (default, 32). <br>
"IntegrationTestTableSnapshotInputFormat.tableDir" =&gt; temporary directory to restore the
snapshot files
hbase-it/src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestTableSnapshotInputFormat.java