@Test
  public void testShutdownWhileBecomingActive() throws InterruptedException {
    SingleProcessHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster activeMaster = null;
    HMaster backupMaster = null;
    for (MasterThread t : cluster.getMasterThreads()) {
      if (t.getMaster().isActiveMaster()) {
        activeMaster = t.getMaster();
      } else {
        backupMaster = t.getMaster();
      }
    }
    assertNotNull(activeMaster);
    assertNotNull(backupMaster);
    ARRIVE = new CountDownLatch(1);
    CONTINUE = new CountDownLatch(1);
    activeMaster.abort("Aborting active master for test");
    // wait until we arrive the initClusterSchemaService
    ARRIVE.await();
    // killall RSes
    cluster.getRegionServerThreads().stream().map(t -> t.getRegionServer())
      .forEachOrdered(rs -> rs.abort("Aborting RS for test"));
    CONTINUE.countDown();
  }
Test to confirm that we will not hang when stop a backup master which is trying to become the
active master. See HBASE-19838
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestShutdownBackupMaster.java