@Test
  public void testScanMultipleVersions() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(HConstants.CATALOG_FAMILY)).build();

    final byte[][] rows = new byte[][] { Bytes.toBytes("row_0200"), Bytes.toBytes("row_0800") };
    final byte[][] splitRows = new byte[][] { Bytes.toBytes("row_0500") };
    final long[] timestamp = new long[] { 100L, 1000L };
    this.admin.createTable(tableDescriptor, splitRows);
    Table table = UTIL.getConnection().getTable(tableName);
    // Assert we got the region layout wanted.
    Pair<byte[][], byte[][]> keys =
      UTIL.getConnection().getRegionLocator(tableName).getStartEndKeys();
    assertEquals(2, keys.getFirst().length);
    byte[][] startKeys = keys.getFirst();
    byte[][] endKeys = keys.getSecond();

    for (int i = 0; i < startKeys.length; i++) {
      if (i == 0) {
        assertArrayEquals(HConstants.EMPTY_START_ROW, startKeys[i]);
        assertArrayEquals(endKeys[i], splitRows[0]);
      } else if (i == 1) {
        assertArrayEquals(splitRows[0], startKeys[i]);
        assertArrayEquals(endKeys[i], HConstants.EMPTY_END_ROW);
      }
    }
    // Insert data
    List<Put> puts = new ArrayList<>();
    for (int i = 0; i < startKeys.length; i++) {
      for (int j = 0; j < timestamp.length; j++) {
        Put put = new Put(rows[i], timestamp[j]);
        put.addColumn(HConstants.CATALOG_FAMILY, null, timestamp[j], Bytes.toBytes(timestamp[j]));
        puts.add(put);
      }
    }
    table.put(puts);
    // There are 5 cases we have to test. Each is described below.
    for (int i = 0; i < rows.length; i++) {
      for (int j = 0; j < timestamp.length; j++) {
        Get get = new Get(rows[i]);
        get.addFamily(HConstants.CATALOG_FAMILY);
        get.setTimestamp(timestamp[j]);
        Result result = table.get(get);
        int cellCount = result.rawCells().length;
        assertEquals(1, cellCount);
      }
    }

    // Case 1: scan with LATEST_TIMESTAMP. Should get two rows
    int count;
    Scan scan = new Scan();
    scan.addFamily(HConstants.CATALOG_FAMILY);
    try (ResultScanner s = table.getScanner(scan)) {
      count = Iterables.size(s);
    }
    assertEquals("Number of rows should be 2", 2, count);

    // Case 2: Scan with a timestamp greater than most recent timestamp
    // (in this case > 1000 and < LATEST_TIMESTAMP. Should get 2 rows.
    scan = new Scan();
    scan.setTimeRange(1000L, Long.MAX_VALUE);
    scan.addFamily(HConstants.CATALOG_FAMILY);
    try (ResultScanner s = table.getScanner(scan)) {
      count = Iterables.size(s);
    }
    assertEquals("Number of rows should be 2", 2, count);

    // Case 3: scan with timestamp equal to most recent timestamp
    // (in this case == 1000. Should get 2 rows.
    scan = new Scan();
    scan.setTimestamp(1000L);
    scan.addFamily(HConstants.CATALOG_FAMILY);
    try (ResultScanner s = table.getScanner(scan)) {
      count = Iterables.size(s);
    }
    assertEquals("Number of rows should be 2", 2, count);

    // Case 4: scan with timestamp greater than first timestamp but less than
    // second timestamp (100 < timestamp < 1000). Should get 2 rows.
    scan = new Scan();
    scan.setTimeRange(100L, 1000L);
    scan.addFamily(HConstants.CATALOG_FAMILY);
    try (ResultScanner s = table.getScanner(scan)) {
      count = Iterables.size(s);
    }
    assertEquals("Number of rows should be 2", 2, count);

    // Case 5: scan with timestamp equal to first timestamp (100)
    // Should get 2 rows.
    scan = new Scan();
    scan.setTimestamp(100L);
    scan.addFamily(HConstants.CATALOG_FAMILY);
    try (ResultScanner s = table.getScanner(scan)) {
      count = Iterables.size(s);
    }
    assertEquals("Number of rows should be 2", 2, count);
  }
Port of old TestScanMultipleVersions test here so can better utilize the spun up cluster
running more than just a single test. Keep old tests crazyness.
<p>
Tests five cases of scans and timestamps.
hbase-server/src/test/java/org/apache/hadoop/hbase/TestMultiVersions.java