private MasterAddressTracker setupMasterTracker(final ServerName sn, final int infoPort)
    throws Exception {
    zk = new ZKWatcher(TEST_UTIL.getConfiguration(), name.getMethodName(), null);
    ZKUtil.createAndFailSilent(zk, zk.getZNodePaths().baseZNode);
    ZKUtil.createAndFailSilent(zk, zk.getZNodePaths().backupMasterAddressesZNode);

    // Should not have a master yet
    MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
    addressTracker.start();
    assertFalse(addressTracker.hasMaster());
    zk.registerListener(addressTracker);

    // Use a listener to capture when the node is actually created
    NodeCreationListener listener =
      new NodeCreationListener(zk, zk.getZNodePaths().masterAddressZNode);
    zk.registerListener(listener);

    if (sn != null) {
      LOG.info("Creating master node");
      MasterAddressTracker.setMasterAddress(zk, zk.getZNodePaths().masterAddressZNode, sn,
        infoPort);

      // Wait for the node to be created
      LOG.info("Waiting for master address manager to be notified");
      listener.waitForCreation();
      LOG.info("Master node created");
    }
    return addressTracker;
  }
create an address tracker instance
@param sn       if not-null set the active master
@param infoPort if there is an active master, set its info port.
hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestMasterAddressTracker.java