@Test
  public void testConflictRegionServerHostnameConfigurationsAbortServer() throws Exception {
    Enumeration<NetworkInterface> netInterfaceList = NetworkInterface.getNetworkInterfaces();
    while (netInterfaceList.hasMoreElements()) {
      NetworkInterface ni = netInterfaceList.nextElement();
      Enumeration<InetAddress> addrList = ni.getInetAddresses();
      // iterate through host addresses and use each as hostname
      while (addrList.hasMoreElements()) {
        InetAddress addr = addrList.nextElement();
        if (addr.isLoopbackAddress() || addr.isLinkLocalAddress() || addr.isMulticastAddress()) {
          continue;
        }
        String hostName = addr.getHostName();
        LOG.info("Found " + hostName + " on " + ni);

        TEST_UTIL.getConfiguration().set(DNS.MASTER_HOSTNAME_KEY, hostName);
        // "hbase.unsafe.regionserver.hostname" and
        // "hbase.unsafe.regionserver.hostname.disable.master.reversedns"
        // are mutually exclusive. Exception should be thrown if both are used.
        TEST_UTIL.getConfiguration().set(DNS.UNSAFE_RS_HOSTNAME_KEY, hostName);
        TEST_UTIL.getConfiguration()
          .setBoolean(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY, true);
        try {
          StartTestingClusterOption option = StartTestingClusterOption.builder()
            .numMasters(NUM_MASTERS).numRegionServers(NUM_RS).numDataNodes(NUM_RS).build();
          TEST_UTIL.startMiniCluster(option);
        } catch (Exception e) {
          Throwable t1 = e.getCause();
          Throwable t2 = t1.getCause();
          assertTrue(t1.getMessage() + " - " + t2.getMessage(),
            t2.getMessage().contains(HRegionServer.UNSAFE_RS_HOSTNAME_DISABLE_MASTER_REVERSEDNS_KEY
              + " and " + DNS.UNSAFE_RS_HOSTNAME_KEY + " are mutually exclusive"));
          return;
        } finally {
          TEST_UTIL.shutdownMiniCluster();
        }
        assertTrue("Failed to validate against conflict hostname configurations", false);
      }
    }
  }
Tests for the hostname specification by region server
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerHostname.java