@Test
  public void testCleaningAndStoreFileReaderCreatedByOtherThreads()
    throws IOException, InterruptedException {
    TableName testTable = TableName.valueOf("testCleaningAndStoreFileReaderCreatedByOtherThreads");
    ColumnFamilyDescriptor cfDesc = ColumnFamilyDescriptorBuilder.newBuilder(fam)
      .setMobEnabled(true).setMobThreshold(mobLen).setMaxVersions(1).build();
    TableDescriptor tDesc =
      TableDescriptorBuilder.newBuilder(testTable).setColumnFamily(cfDesc).build();
    admin.createTable(tDesc);
    assertTrue(admin.tableExists(testTable));

    // put some data
    loadData(admin.getConnection().getTable(testTable), 0, 10);

    HRegion region = HTU.getHBaseCluster().getRegions(testTable).get(0);
    HStore store = region.getStore(fam);
    Collection<HStoreFile> storeFiles = store.getStorefiles();
    assertEquals(1, store.getStorefiles().size());
    final HStoreFile sf = storeFiles.iterator().next();
    assertNotNull(sf);
    long mobFileNum = getNumberOfMobFiles(conf, testTable, new String(fam));
    assertEquals(1, mobFileNum);

    ServerName serverName = null;
    for (ServerName sn : admin.getRegionServers()) {
      boolean flag = admin.getRegions(sn).stream().anyMatch(
        r -> r.getRegionNameAsString().equals(region.getRegionInfo().getRegionNameAsString()));
      if (flag) {
        serverName = sn;
        break;
      }
    }
    assertNotNull(serverName);
    RSMobFileCleanerChore cleanerChore =
      HTU.getHBaseCluster().getRegionServer(serverName).getRSMobFileCleanerChore();
    CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
      boolean readerIsNotNull = false;
      try {
        sf.initReader();
        Thread.sleep(1000 * 10);
        readerIsNotNull = sf.getReader() != null;
        sf.closeStoreFile(true);
      } catch (Exception e) {
        LOG.error("We occur an exception", e);
      }
      return readerIsNotNull;
    });
    Thread.sleep(100);
    // The StoreFileReader object was created by another thread
    cleanerChore.chore();
    Boolean readerIsNotNull = future.join();
    assertTrue(readerIsNotNull);
    admin.disableTable(testTable);
    admin.deleteTable(testTable);
  }
Mob file cleaner chore test. 1. Creates MOB table 2. Load MOB data and flushes it N times 3. Runs
major MOB compaction 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
every old MOB file referenced from current RS was archived
hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestRSMobFileCleanerChore.java