public static void stopMasterAndCacheMetaLocation(HBaseTestingUtil HTU)
    throws IOException, InterruptedException {
    // cache meta location, so we will not go to master to lookup meta region location
    for (JVMClusterUtil.RegionServerThread t : HTU.getMiniHBaseCluster().getRegionServerThreads()) {
      try (RegionLocator locator =
        t.getRegionServer().getConnection().getRegionLocator(TableName.META_TABLE_NAME)) {
        locator.getAllRegionLocations();
      }
    }
    try (RegionLocator locator = HTU.getConnection().getRegionLocator(TableName.META_TABLE_NAME)) {
      locator.getAllRegionLocations();
    }
    // Stop master
    HMaster master = HTU.getHBaseCluster().getMaster();
    Thread masterThread = HTU.getHBaseCluster().getMasterThread();
    master.stopMaster();

    LOG.info("Waiting until master thread exits");
    while (masterThread != null && masterThread.isAlive()) {
      Threads.sleep(100);
    }

    HRegionServer.TEST_SKIP_REPORTING_TRANSITION = true;
  }
Tests on the region server, without the master.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java