@Override
  public void perform() throws Exception {
    HBaseTestingUtil util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getAdmin();

    getLogger().info("Performing action: Merge random adjacent regions of table " + tableName);
    List<RegionInfo> regions = admin.getRegions(tableName);
    if (regions == null || regions.size() < 2) {
      getLogger().info("Table " + tableName + " doesn't have enough regions to merge");
      return;
    }

    int i = ThreadLocalRandom.current().nextInt(regions.size() - 1);
    RegionInfo a = regions.get(i++);
    RegionInfo b = regions.get(i);
    getLogger().debug("Merging " + a.getRegionNameAsString() + " and " + b.getRegionNameAsString());

    // Don't try the merge if we're stopping
    if (context.isStopping()) {
      return;
    }

    try {
      admin.mergeRegionsAsync(a.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), false).get();
    } catch (Exception ex) {
      getLogger().warn("Merge failed, might be caused by other chaos: " + ex.getMessage());
    }
    if (sleepTime > 0) {
      Thread.sleep(sleepTime);
    }
  }
Action to merge regions of a table.
hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/MergeRandomAdjacentRegionsOfTableAction.java