X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FFollowerLogInformationImplTest.java;h=d68339ee8664f445b02a54cc46fb705bb3bf559e;hb=19d69c253556e008af6488c4a7f0e424916938bd;hp=843b9bebbd3956a3bda56c251a03e697bbc72867;hpb=ac5bcae15c3c9831f2879ae44c66b39130e3f2fe;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java index 843b9bebbd..d68339ee86 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java @@ -7,8 +7,10 @@ */ package org.opendaylight.controller.cluster.raft; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; + import com.google.common.base.Stopwatch; import com.google.common.util.concurrent.Uninterruptibles; import java.util.concurrent.TimeUnit; @@ -62,7 +64,7 @@ public class FollowerLogInformationImplTest { } @Test - public void testOkToReplicate(){ + public void testOkToReplicate() { MockRaftActorContext context = new MockRaftActorContext(); context.setCommitIndex(0); FollowerLogInformation followerLogInformation = @@ -111,4 +113,21 @@ public class FollowerLogInformationImplTest { followerLogInformation.markFollowerActive(); assertTrue(followerLogInformation.isFollowerActive()); } + + @Test + public void testDecrNextIndex() { + MockRaftActorContext context = new MockRaftActorContext(); + context.setCommitIndex(1); + FollowerLogInformation followerLogInformation = + new FollowerLogInformationImpl(new PeerInfo("follower1", null, VotingState.VOTING), 1, context); + + assertTrue(followerLogInformation.decrNextIndex()); + assertEquals("getNextIndex", 0, followerLogInformation.getNextIndex()); + + assertTrue(followerLogInformation.decrNextIndex()); + assertEquals("getNextIndex", -1, followerLogInformation.getNextIndex()); + + assertFalse(followerLogInformation.decrNextIndex()); + assertEquals("getNextIndex", -1, followerLogInformation.getNextIndex()); + } }