@Test
  public void testTruncateRegion() throws Exception {
    // Arrange - Create table, insert data, identify region to truncate.
    final byte[][] splitKeys =
      new byte[][] { Bytes.toBytes("30"), Bytes.toBytes("60"), Bytes.toBytes("90") };
    String family1 = "f1";
    String family2 = "f2";

    final String[] sFamilies = new String[] { family1, family2 };
    final byte[][] bFamilies = new byte[][] { Bytes.toBytes(family1), Bytes.toBytes(family2) };
    createTableWithDefaultConf(tableName, splitKeys, bFamilies);

    AsyncTable<AdvancedScanResultConsumer> metaTable = ASYNC_CONN.getTable(META_TABLE_NAME);
    List<HRegionLocation> regionLocations =
      ClientMetaTableAccessor.getTableHRegionLocations(metaTable, tableName).get();
    RegionInfo regionToBeTruncated = regionLocations.get(0).getRegion();

    assertEquals(4, regionLocations.size());

    AssignmentTestingUtil.insertData(TEST_UTIL, tableName, 2, 21, sFamilies);
    AssignmentTestingUtil.insertData(TEST_UTIL, tableName, 2, 31, sFamilies);
    AssignmentTestingUtil.insertData(TEST_UTIL, tableName, 2, 61, sFamilies);
    AssignmentTestingUtil.insertData(TEST_UTIL, tableName, 2, 91, sFamilies);
    int rowCountBeforeTruncate = TEST_UTIL.countRows(tableName);

    // Act - Truncate the first region
    admin.truncateRegion(regionToBeTruncated.getRegionName()).get();

    // Assert
    int rowCountAfterTruncate = TEST_UTIL.countRows(tableName);
    assertNotEquals(rowCountBeforeTruncate, rowCountAfterTruncate);
    int expectedRowCount = rowCountBeforeTruncate - 2;// Since region with 2 rows was truncated.
    assertEquals(expectedRowCount, rowCountAfterTruncate);
  }
Class to test asynchronous region admin operations.
@see TestAsyncRegionAdminApi This test and it used to be joined it was taking longer than our ten
     minute timeout so they were split.
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionAdminApi2.java