consensus-raft/src/test/java/com/mboysan/consensus/RaftNodeTest.java
/**
     * Tests append event during a broken quorum and the leader is not changed after the quorum is reestablished.
     * Append will succeed.
     */
Tests append event during a broken quorum and the leader is not changed after the quorum is reestablished.
Append will succeed.
Tests append event during a broken quorum and the leader is not changed after the quorum is reestablished . Append will succeed .
@Disabled
    @Test
    void testAppendWhenQuorumNotFormed2() throws Exception {
        int numServers = 5;
        init(numServers);
        int leaderId = assertOneLeader();
        kill((leaderId + 1) % numServers);
        kill((leaderId + 2) % numServers);
        kill((leaderId + 3) % numServers);
        advanceTimeForElections();
        List<String> expectedCommands = List.of("cmd0");
        Future<Boolean> result0 = getNode(leaderId).append(expectedCommands.get(0));
        assertThrows(TimeoutException.class, () -> result0.get(1, TimeUnit.SECONDS));
        advanceTimeForElections();
        revive((leaderId + 1) % numServers);
        revive((leaderId + 2) % numServers);
        revive((leaderId + 3) % numServers);
        advanceTimeForElections();
        assertLeaderNotChanged(leaderId);   
        assertTrue(result0.get());  
        assertLogsEquals(expectedCommands);
    }
@ Disabled @ Test void testAppendWhenQuorumNotFormed2 ( ) throws Exception { int numServers = 5 ; init ( numServers ) ; int leaderId = assertOneLeader ( ) ; kill ( ( leaderId + 1 ) % numServers ) ; kill ( ( leaderId + 2 ) % numServers ) ; kill ( ( leaderId + 3 ) % numServers ) ; advanceTimeForElections ( ) ; List < String > expectedCommands = List . of ( "cmd0" ) ; Future < Boolean > result0 = getNode ( leaderId ) . append ( expectedCommands . get ( 0 ) ) ; assertThrows ( TimeoutException . class , ( ) -> result0 . get ( 1 , TimeUnit . SECONDS ) ) ; advanceTimeForElections ( ) ; revive ( ( leaderId + 1 ) % numServers ) ; revive ( ( leaderId + 2 ) % numServers ) ; revive ( ( leaderId + 3 ) % numServers ) ; advanceTimeForElections ( ) ; assertLeaderNotChanged ( leaderId ) ; assertTrue ( result0 . get ( ) ) ; assertLogsEquals ( expectedCommands ) ; }
Tests append event during a broken quorum and the leader is not changed after the quorum is reestablished.
Tests append event during a broken quorum and the leader is not changed after the quorum is reestablished .
// new leader won't be elected // fixme: doesn't work properly due to leader being changed after revival of killed nodes. This is normal but makes test unusable. // the cmd should be applied and synced.