public List<RegionInfo> createMultiRegionsInMeta(final Configuration conf,
    final TableDescriptor htd, byte[][] startKeys) throws IOException {
    try (Table meta = getConnection().getTable(TableName.META_TABLE_NAME)) {
      Arrays.sort(startKeys, Bytes.BYTES_COMPARATOR);
      List<RegionInfo> newRegions = new ArrayList<>(startKeys.length);
      MetaTableAccessor.updateTableState(getConnection(), htd.getTableName(),
        TableState.State.ENABLED);
      // add custom ones
      for (int i = 0; i < startKeys.length; i++) {
        int j = (i + 1) % startKeys.length;
        RegionInfo hri = RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(startKeys[i])
          .setEndKey(startKeys[j]).build();
        MetaTableAccessor.addRegionsToMeta(getConnection(), Collections.singletonList(hri), 1);
        newRegions.add(hri);
      }
      return newRegions;
    }
  }
Create rows in hbase:meta for regions of the specified table with the specified start keys. The
first startKey should be a 0 length byte array if you want to form a proper range of regions.
@return list of region info for regions added to meta
hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtil.java