public void ensureLeader(final Endpoint expectAddr) throws InterruptedException {
        while (true) {
            this.lock.lock();
            for (final Node node : this.nodes) {
                final PeerId leaderId = node.getLeaderId();
                if (!leaderId.getEndpoint().equals(expectAddr)) {
                    this.lock.unlock();
                    Thread.sleep(10);
                    continue;
                }
            }
            // all is ready
            this.lock.unlock();
            return;
        }
    }
Ensure all peers leader is expectAddr
@param expectAddr expected address
@throws InterruptedException if interrupted
jraft-core/src/test/java/com/alipay/sofa/jraft/core/TestCluster.java