@Before
  public void setUp() throws Exception {
    System.setProperty(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES, "true");
    while (server == null) {
      try {
        server = new TestingServer();
      } catch (BindException e) {
        LOG.warn("Getting bind exception - retrying to allocate server");
        server = null;
      }
    }
  }
See SlotZNode; some tests (and the setup) are c/p-ed or modified from Curator.
llap-client/src/test/org/apache/hadoop/hive/llap/registry/impl/TestSlotZnode.java