@Test
  public void testSplitTmpFileCleanUp() throws Exception {
    final TableName table = TableName.valueOf(name.getMethodName());
    byte[][] SPLIT_KEYS = new byte[][] { Bytes.toBytes("row_00000010"),
      Bytes.toBytes("row_00000020"), Bytes.toBytes("row_00000030"), Bytes.toBytes("row_00000040"),
      Bytes.toBytes("row_00000050") };
    setupTableWithSplitkeys(table, 10, SPLIT_KEYS);

    BulkLoadHFiles loader = BulkLoadHFiles.create(util.getConfiguration());

    // create HFiles
    Path dir = buildBulkFiles(table, 2);
    loader.bulkLoad(table, dir);
    // family path
    Path tmpPath = new Path(dir, family(0));
    // TMP_DIR under family path
    tmpPath = new Path(tmpPath, BulkLoadHFilesTool.TMP_DIR);
    FileSystem fs = dir.getFileSystem(util.getConfiguration());
    // HFiles have been splitted, there is TMP_DIR
    assertTrue(fs.exists(tmpPath));
    // TMP_DIR should have been cleaned-up
    assertNull(BulkLoadHFilesTool.TMP_DIR + " should be empty.",
      CommonFSUtils.listStatus(fs, tmpPath));
    assertExpectedTable(util.getConnection(), table, ROWCOUNT, 2);
  }
This test creates a table with many small regions. The bulk load files would be splitted
multiple times before all of them can be loaded successfully.
hbase-server/src/test/java/org/apache/hadoop/hbase/tool/TestBulkLoadHFilesSplitRecovery.java