Search in sources :

Example 1 with LocalRaftGroup

use of com.hazelcast.cp.internal.raft.impl.testing.LocalRaftGroup in project hazelcast by hazelcast.

the class LocalRaftTest method when_leaderStaysInMinorityDuringSplit_thenItMergesBackSuccessfully.

@Test
public void when_leaderStaysInMinorityDuringSplit_thenItMergesBackSuccessfully() {
    int nodeCount = 5;
    group = new LocalRaftGroup(nodeCount);
    group.start();
    RaftEndpoint leaderEndpoint = group.waitUntilLeaderElected().getLocalMember();
    int[] split = group.createMajoritySplitIndexes(false);
    group.split(split);
    assertTrueEventually(() -> {
        for (int ix : split) {
            RaftEndpoint newLeader = getLeaderMember(group.getNode(ix));
            assertNotNull(newLeader);
            assertNotEquals(leaderEndpoint, newLeader);
        }
    });
    assertTrueEventually(() -> {
        for (int i = 0; i < nodeCount; i++) {
            if (Arrays.binarySearch(split, i) < 0) {
                assertNull(getLeaderMember(group.getNode(i)));
            }
        }
    });
    group.merge();
    group.waitUntilLeaderElected();
}
Also used : LocalRaftGroup(com.hazelcast.cp.internal.raft.impl.testing.LocalRaftGroup) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with LocalRaftGroup

use of com.hazelcast.cp.internal.raft.impl.testing.LocalRaftGroup in project hazelcast by hazelcast.

the class LocalRaftTest method when_leaderStaysInMajorityDuringSplit_thenItMergesBackSuccessfully.

@Test
public void when_leaderStaysInMajorityDuringSplit_thenItMergesBackSuccessfully() {
    group = new LocalRaftGroup(5);
    group.start();
    group.waitUntilLeaderElected();
    int[] split = group.createMinoritySplitIndexes(false);
    group.split(split);
    assertTrueEventually(() -> {
        for (int ix : split) {
            assertNull(getLeaderMember(group.getNode(ix)));
        }
    });
    group.merge();
    group.waitUntilLeaderElected();
}
Also used : LocalRaftGroup(com.hazelcast.cp.internal.raft.impl.testing.LocalRaftGroup) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LocalRaftGroup (com.hazelcast.cp.internal.raft.impl.testing.LocalRaftGroup)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2