code: public void waitForNewMaster(int timeoutMs) throws TimeoutException, InterruptedException {
      CommonUtils.waitFor("the new leader master to start", () -> getLeaderIndex() != -1,
          WaitForOptions.defaults().setTimeoutMs(timeoutMs));
    }
docs: Waits for a new master to start until a timeout occurs.
  
  @param timeoutMs the number of milliseconds to wait before giving up and throwing an exception