@Test
  public void testBypass() throws IOException, InterruptedException {
    Admin admin = TEST_UTIL.getAdmin();
    MasterProcedureEnv env =
      TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment();
    List<RegionInfo> regions = admin.getRegions(this.tableName);
    for (RegionInfo ri : regions) {
      admin.unassign(ri.getRegionName());
    }
    List<Long> pids = new ArrayList<>(regions.size());
    for (RegionInfo ri : regions) {
      Procedure<MasterProcedureEnv> p =
        new StallingAssignProcedure(env, ri, null, false, TransitionType.ASSIGN);
      pids.add(
        TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().submitProcedure(p));
    }
    TEST_UTIL.waitFor(30000, () -> pids.stream().allMatch(
      pid -> TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().isStarted(pid)));
    List<Procedure<MasterProcedureEnv>> ps =
      TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().getProcedures();
    for (Procedure<MasterProcedureEnv> p : ps) {
      if (p instanceof StallingAssignProcedure) {
        List<Boolean> bs =
          TEST_UTIL.getHbck().bypassProcedure(Arrays.asList(p.getProcId()), 1000, true, false);
        for (Boolean b : bs) {
          LOG.info("BYPASSED {} {}", p.getProcId(), b);
        }
      }
    }
    // Try and assign WITHOUT override flag. Should fail!.
    for (RegionInfo ri : regions) {
      IOException error = assertThrows(IOException.class, () -> admin.assign(ri.getRegionName()));
      LOG.info("Expected {}", error);
    }
    TEST_UTIL.waitFor(30000, () -> TEST_UTIL.getHBaseCluster().getMaster()
      .getMasterProcedureExecutor().getActiveProcIds().isEmpty());
    // Now assign with the override flag.
    for (RegionInfo ri : regions) {
      TEST_UTIL.getHbck().assigns(Arrays.<String> asList(ri.getEncodedName()), true, true);
    }
    TEST_UTIL.waitFor(60000, () -> TEST_UTIL.getHBaseCluster().getMaster()
      .getMasterProcedureExecutor().getActiveProcIds().isEmpty());
    for (RegionInfo ri : regions) {
      assertTrue(ri.toString(), TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
        .getRegionStates().isRegionOnline(ri));
    }
  }
Tests bypass on a region assign/unassign
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRegionBypass.java