@Test
    public void testTripleNodes() throws Exception {
        final List<PeerId> peers = TestUtils.generatePeers(3);

        final TestCluster cluster = new TestCluster("unittest", this.dataPath, peers);
        for (final PeerId peer : peers) {
            assertTrue(cluster.start(peer.getEndpoint()));
        }

        // elect leader
        cluster.waitLeader();

        // get leader
        final Node leader = cluster.getLeader();
        assertEquals(1, leader.getLastAppliedLogIndex());
        assertEquals(1, leader.getLastCommittedIndex());
        assertEquals(1, leader.getLastLogIndex());
        assertNotNull(leader);
        assertEquals(3, leader.listPeers().size());
        // apply tasks to leader
        this.sendTestTaskAndWait(leader);

        assertEquals(11, leader.getLastCommittedIndex());
        assertEquals(11, leader.getLastLogIndex());
        Thread.sleep(500);
        assertEquals(11, leader.getLastAppliedLogIndex());

        {
            final ByteBuffer data = ByteBuffer.wrap("no closure".getBytes());
            final Task task = new Task(data, null);
            leader.apply(task);
        }

        {
            // task with TaskClosure
            final ByteBuffer data = ByteBuffer.wrap("task closure".getBytes());
            final Vector<String> cbs = new Vector<>();
            final CountDownLatch latch = new CountDownLatch(1);
            final Task task = new Task(data, new TaskClosure() {

                @Override
                public void run(final Status status) {
                    cbs.add("apply");
                    latch.countDown();
                }

                @Override
                public void onCommitted() {
                    cbs.add("commit");

                }
            });
            leader.apply(task);
            latch.await();
            assertEquals(2, cbs.size());
            assertEquals("commit", cbs.get(0));
            assertEquals("apply", cbs.get(1));
        }

        assertEquals(13, leader.getLastCommittedIndex());
        assertEquals(13, leader.getLastLogIndex());
        Thread.sleep(500);
        assertEquals(13, leader.getLastAppliedLogIndex());

        cluster.ensureSame(-1);
        assertEquals(2, cluster.getFollowers().size());
        for (Node follower : cluster.getFollowers()) {
            assertEquals(13, follower.getLastCommittedIndex());
            assertEquals(13, follower.getLastLogIndex());
            assertEquals(13, follower.getLastAppliedLogIndex());
        }
        cluster.stopAll();
    }
Test rollback stateMachine with readIndex for issue 317:
https://github.com/sofastack/sofa-jraft/issues/317
jraft-core/src/test/java/com/alipay/sofa/jraft/core/NodeTest.java