@Test
  public void testBasicScenario() throws Exception {
    // keep 3 versions, rows do not expire
    TableDescriptor htd = hbu.createTableDescriptor(TableName.valueOf(name.getMethodName()), 0, 3,
      HConstants.FOREVER, KeepDeletedCells.TRUE);
    HRegion region = hbu.createLocalHRegion(htd, null, null);

    long ts = EnvironmentEdgeManager.currentTime();
    Put p = new Put(T1, ts);
    p.addColumn(c0, c0, T1);
    region.put(p);
    p = new Put(T1, ts + 1);
    p.addColumn(c0, c0, T2);
    region.put(p);
    p = new Put(T1, ts + 2);
    p.addColumn(c0, c0, T3);
    region.put(p);
    p = new Put(T1, ts + 4);
    p.addColumn(c0, c0, T4);
    region.put(p);

    // now place a delete marker at ts+2
    Delete d = new Delete(T1, ts + 2);
    region.delete(d);

    // a raw scan can see the delete markers
    // (one for each column family)
    assertEquals(3, countDeleteMarkers(region));

    // get something *before* the delete marker
    Get g = new Get(T1);
    g.readAllVersions();
    g.setTimeRange(0L, ts + 2);
    Result r = region.get(g);
    checkResult(r, c0, c0, T2, T1);

    // flush
    region.flush(true);

    // yep, T2 still there, T1 gone
    r = region.get(g);
    checkResult(r, c0, c0, T2);

    // major compact
    region.compact(true);
    region.compact(true);

    // one delete marker left (the others did not
    // have older puts)
    assertEquals(1, countDeleteMarkers(region));

    // still there (even after multiple compactions)
    r = region.get(g);
    checkResult(r, c0, c0, T2);

    // a timerange that includes the delete marker won't see past rows
    g.setTimeRange(0L, ts + 4);
    r = region.get(g);
    assertTrue(r.isEmpty());

    // two more puts, this will expire the older puts.
    p = new Put(T1, ts + 5);
    p.addColumn(c0, c0, T5);
    region.put(p);
    p = new Put(T1, ts + 6);
    p.addColumn(c0, c0, T6);
    region.put(p);

    // also add an old put again
    // (which is past the max versions)
    p = new Put(T1, ts);
    p.addColumn(c0, c0, T1);
    region.put(p);
    r = region.get(g);
    assertTrue(r.isEmpty());

    region.flush(true);
    region.compact(true);
    region.compact(true);

    // verify that the delete marker itself was collected
    region.put(p);
    r = region.get(g);
    checkResult(r, c0, c0, T1);
    assertEquals(0, countDeleteMarkers(region));

    HBaseTestingUtil.closeRegionAndWAL(region);
  }
Make sure that deleted rows are retained. Family delete markers are deleted. Column Delete
markers are versioned Time range scan of deleted rows are possible
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java