@After public void tearDown() { final MiniRaftCluster cluster = getCluster(); if (cluster != null) { cluster.shutdown(); } }
@Test public void testBasicAppendEntries() throws Exception { runTestBasicAppendEntries(false, ReplicationLevel.MAJORITY, false, 10, getCluster(), LOG); }
@Test public void testBasicAppendEntriesKillLeader() throws Exception { runTestBasicAppendEntries(false, ReplicationLevel.MAJORITY, true, 10, getCluster(), LOG); }
@Before public void setup() throws IOException { Assert.assertNull(getCluster().getLeader()); getCluster().start(); }
@Test public void testDelayRequestIfLeaderStepDown() throws Exception { runTestDelayRequestIfLeaderStepDown(false, getCluster(), LOG); }
@Test public void testBasicAppendEntriesWithAllReplication() throws Exception { runTestBasicAppendEntries(false, ReplicationLevel.ALL, false, 10, getCluster(), LOG); }
@Test public void testWithLoad() throws Exception { testWithLoad(10, 500, false, getCluster(), LOG); }
@Test public void testOldLeaderCommit() throws Exception { LOG.info("Running testOldLeaderCommit"); final MiniRaftCluster cluster = getCluster(); final RaftServerImpl leader = waitForLeader(cluster); final RaftPeerId leaderId = leader.getId();
@Test public void testOldLeaderNotCommit() throws Exception { LOG.info("Running testOldLeaderNotCommit"); final MiniRaftCluster cluster = getCluster(); final RaftPeerId leaderId = waitForLeader(cluster).getId(); List<RaftServerImpl> followers = cluster.getFollowers(); final RaftServerImpl followerToCommit = followers.get(0); for (int i = 1; i < NUM_SERVERS - 1; i++) { RaftServerImpl follower = followers.get(i); cluster.killServer(follower.getId()); } SimpleMessage[] messages = SimpleMessage.create(1); sendMessageInNewThread(cluster, messages); Thread.sleep(cluster.getMaxTimeout() + 100); logEntriesContains(followerToCommit.getState().getLog(), messages); cluster.killServer(leaderId); cluster.killServer(followerToCommit.getId()); for (int i = 1; i < NUM_SERVERS - 1; i++) { RaftServerImpl follower = followers.get(i); cluster.restartServer(follower.getId(), false ); } waitForLeader(cluster); Thread.sleep(cluster.getMaxTimeout() + 100); final Predicate<LogEntryProto> predicate = l -> l.getTerm() != 1; cluster.getServerAliveStream() .map(s -> s.getState().getLog()) .forEach(log -> RaftTestUtil.checkLogEntries(log, messages, predicate)); }