@Test
  public void testMobFileCleanerChore() throws InterruptedException, IOException {

    loadData(0, 10);
    loadData(10, 10);
    loadData(20, 10);
    long num = getNumberOfMobFiles(conf, table.getName(), new String(fam));
    assertEquals(3, num);
    // Major compact
    admin.majorCompact(tableDescriptor.getTableName(), fam);
    // wait until compaction is complete
    while (admin.getCompactionState(tableDescriptor.getTableName()) != CompactionState.NONE) {
      Thread.sleep(100);
    }

    num = getNumberOfMobFiles(conf, table.getName(), new String(fam));
    assertEquals(4, num);
    // We have guarantee, that compcated file discharger will run during this pause
    // because it has interval less than this wait time
    LOG.info("Waiting for {}ms", minAgeToArchive + 1000);

    Thread.sleep(minAgeToArchive + 1000);
    LOG.info("Cleaning up MOB files");
    // Cleanup
    MobFileCleanupUtil.cleanupObsoleteMobFiles(conf, table.getName(), admin);

    // verify that nothing have happened
    num = getNumberOfMobFiles(conf, table.getName(), new String(fam));
    assertEquals(4, num);

    long scanned = scanTable();
    assertEquals(30, scanned);

    // add a MOB file to with a name refering to a non-existing region
    Path extraMOBFile = MobTestUtil.generateMOBFileForRegion(conf, table.getName(),
      familyDescriptor, "nonExistentRegion");
    num = getNumberOfMobFiles(conf, table.getName(), new String(fam));
    assertEquals(5, num);

    LOG.info("Waiting for {}ms", minAgeToArchive + 1000);

    Thread.sleep(minAgeToArchive + 1000);
    LOG.info("Cleaning up MOB files");
    MobFileCleanupUtil.cleanupObsoleteMobFiles(conf, table.getName(), admin);

    // check that the extra file got deleted
    num = getNumberOfMobFiles(conf, table.getName(), new String(fam));
    assertEquals(4, num);

    FileSystem fs = FileSystem.get(conf);
    assertFalse(fs.exists(extraMOBFile));

    scanned = scanTable();
    assertEquals(30, scanned);

  }
Mob file cleaner chore test. 1. Creates MOB table 2. Load MOB data and flushes it N times 3. Runs
major MOB compaction (N MOB files go to archive) 4. Verifies that number of MOB files in a mob
directory is N+1 5. Waits for a period of time larger than minimum age to archive 6. Runs Mob
cleaner chore 7 Verifies that number of MOB files in a mob directory is 1.
hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobFileCleanupUtil.java