X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2Fbehaviors%2FLeaderTest.java;h=9e91e514d7efcd62579dbf38ab3e7433cb93541a;hp=41278799ed934ae95c9b7d3dee4f974892c4462e;hb=95d3c7975a423951dcbdecfbfa4cb6b7a23591cc;hpb=d3e310b940b60f6590f0e94a576aece95a055942 diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java index 41278799ed..9e91e514d7 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.raft.behaviors; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; @@ -586,7 +587,7 @@ public class LeaderTest extends AbstractLeaderTest { commitIndex, snapshotTerm, commitIndex, snapshotTerm)); LeaderInstallSnapshotState fts = new LeaderInstallSnapshotState(bs, actorContext.getConfigParams().getSnapshotChunkSize(), leader.logName()); - leader.setFollowerSnapshot(FOLLOWER_ID, fts); + leader.getFollower(FOLLOWER_ID).setLeaderInstallSnapshotState(fts); //send first chunk and no InstallSnapshotReply received yet fts.getNextChunk(); @@ -920,7 +921,7 @@ public class LeaderTest extends AbstractLeaderTest { commitIndex, snapshotTerm, commitIndex, snapshotTerm)); LeaderInstallSnapshotState fts = new LeaderInstallSnapshotState(bs, actorContext.getConfigParams().getSnapshotChunkSize(), leader.logName()); - leader.setFollowerSnapshot(FOLLOWER_ID, fts); + leader.getFollower(FOLLOWER_ID).setLeaderInstallSnapshotState(fts); while(!fts.isLastChunk(fts.getChunkIndex())) { fts.getNextChunk(); fts.incrementChunkIndex(); @@ -934,12 +935,13 @@ public class LeaderTest extends AbstractLeaderTest { assertTrue(raftBehavior instanceof Leader); - assertEquals(0, leader.followerSnapshotSize()); assertEquals(1, leader.followerLogSize()); FollowerLogInformation fli = leader.getFollower(FOLLOWER_ID); assertNotNull(fli); + assertNull(fli.getInstallSnapshotState()); assertEquals(commitIndex, fli.getMatchIndex()); assertEquals(commitIndex + 1, fli.getNextIndex()); + assertFalse(leader.hasSnapshot()); } @Test @@ -1147,19 +1149,8 @@ public class LeaderTest extends AbstractLeaderTest { } @Test - public void testFollowerToSnapshotLogic() { - logStart("testFollowerToSnapshotLogic"); - - MockRaftActorContext actorContext = createActorContext(); - - actorContext.setConfigParams(new DefaultConfigParamsImpl() { - @Override - public int getSnapshotChunkSize() { - return 50; - } - }); - - leader = new Leader(actorContext); + public void testLeaderInstallSnapshotState() { + logStart("testLeaderInstallSnapshotState"); Map leadersSnapshot = new HashMap<>(); leadersSnapshot.put("1", "A"); @@ -1169,9 +1160,7 @@ public class LeaderTest extends AbstractLeaderTest { ByteString bs = toByteString(leadersSnapshot); byte[] barray = bs.toByteArray(); - LeaderInstallSnapshotState fts = new LeaderInstallSnapshotState(bs, - actorContext.getConfigParams().getSnapshotChunkSize(), leader.logName()); - leader.setFollowerSnapshot(FOLLOWER_ID, fts); + LeaderInstallSnapshotState fts = new LeaderInstallSnapshotState(bs, 50, "test"); assertEquals(bs.size(), barray.length);