private void testSplits(TableName tableName, byte[][] splits) throws IOException { // This logic was borrowed from AbstractTestCreateTable.testFiveRegionSplit() List<HRegionLocation> regions = null; try (RegionLocator locator = getConnection().getRegionLocator(tableName)) { regions = locator.getAllRegionLocations(); } // The number of regions should be the number of splits + 1. Assert.assertEquals(splits.length + 1, regions.size()); AbstractTestCreateTable.assertSplitsAndRegionsMatch(splits, regions); }
@Test public void testSplitKeys()throws Exception { byte[][] splits = new byte[][] { Bytes.toBytes("AAA"), Bytes.toBytes("BBB"), Bytes.toBytes("CCC"), }; TableName tableName = sharedTestEnv.newTestTableName(); try { createTable(tableName, splits); List<HRegionLocation> regions = null; try (RegionLocator locator = getConnection().getRegionLocator(tableName)) { regions = locator.getAllRegionLocations(); } // The number of regions should be the number of splits + 1. Assert.assertEquals(splits.length + 1, regions.size()); assertSplitsAndRegionsMatch(splits, regions); } finally { deleteTable(tableName); } }