@Test
  public void testScanWithCompactionAfterFlush() throws Exception {
    TEST_UTIL.getConfiguration().set(DEFAULT_COMPACTION_POLICY_CLASS_KEY,
      EverythingPolicy.class.getName());
    init(name.getMethodName());

    assertEquals(0, this.store.getStorefilesCount());

    KeyValue kv = new KeyValue(row, family, qf1, 1, (byte[]) null);
    // add some data, flush
    this.store.add(kv, null);
    flush(1);
    kv = new KeyValue(row, family, qf2, 1, (byte[]) null);
    // add some data, flush
    this.store.add(kv, null);
    flush(2);
    kv = new KeyValue(row, family, qf3, 1, (byte[]) null);
    // add some data, flush
    this.store.add(kv, null);
    flush(3);

    ExecutorService service = Executors.newFixedThreadPool(2);

    Scan scan = new Scan(new Get(row));
    Future<KeyValueScanner> scanFuture = service.submit(() -> {
      try {
        LOG.info(">>>> creating scanner");
        return this.store.createScanner(scan,
          new ScanInfo(HBaseConfiguration.create(),
            ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(4).build(),
            Long.MAX_VALUE, 0, CellComparator.getInstance()),
          scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);
      } catch (IOException e) {
        e.printStackTrace();
        return null;
      }
    });
    Future compactFuture = service.submit(() -> {
      try {
        LOG.info(">>>>>> starting compaction");
        Optional<CompactionContext> opCompaction = this.store.requestCompaction();
        assertTrue(opCompaction.isPresent());
        store.compact(opCompaction.get(), new NoLimitThroughputController(), User.getCurrent());
        LOG.info(">>>>>> Compaction is finished");
        this.store.closeAndArchiveCompactedFiles();
        LOG.info(">>>>>> Compacted files deleted");
      } catch (IOException e) {
        e.printStackTrace();
      }
    });

    KeyValueScanner kvs = scanFuture.get();
    compactFuture.get();
    ((StoreScanner) kvs).currentScanners.forEach(s -> {
      if (s instanceof StoreFileScanner) {
        assertEquals(1, ((StoreFileScanner) s).getReader().getRefCount());
      }
    });
    kvs.seek(kv);
    service.shutdownNow();
  }
Test for HBASE-3492 - Test split on empty colfam (no store files).
@throws IOException When the IO operations fail.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java