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%2FPreLeaderScenarioTest.java;h=1966e57f80f88e112e15bffbfc0ef22d5325d97a;hb=88a7f904602133bb803752848bb58c9b0a3e9792;hp=d451ea176d7a0bf2251fb336dbcad9a0c09ae7bc;hpb=d86f990976dcc2879b40dec7df1b3b5fba8cba78;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/PreLeaderScenarioTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/PreLeaderScenarioTest.java index d451ea176d..1966e57f80 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/PreLeaderScenarioTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/PreLeaderScenarioTest.java @@ -11,10 +11,8 @@ import static org.junit.Assert.assertEquals; import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages; import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching; import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching; -import akka.actor.Actor; + import akka.actor.ActorRef; -import akka.actor.Props; -import akka.testkit.TestActorRef; import com.google.common.collect.ImmutableMap; import java.util.List; import java.util.concurrent.TimeUnit; @@ -36,11 +34,11 @@ import scala.concurrent.duration.FiniteDuration; */ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest { - private TestActorRef follower1NotifierActor; + private ActorRef follower1NotifierActor; private DefaultConfigParamsImpl followerConfigParams; @Test - public void testUnComittedEntryOnLeaderChange() throws Exception { + public void testUnComittedEntryOnLeaderChange() { testLog.info("testUnComittedEntryOnLeaderChange starting"); createRaftActors(); @@ -81,7 +79,7 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest { assertEquals("Role change 2", RaftState.PreLeader.name(), roleChange.get(1).getNewRole()); assertEquals("Role change 3", RaftState.Leader.name(), roleChange.get(2).getNewRole()); - long previousTerm = currentTerm; + final long previousTerm = currentTerm; currentTerm = follower1Context.getTermInformation().getCurrentTerm(); // Since it went to Leader, it should've appended and successfully replicated a NoopPaylod with the @@ -110,8 +108,8 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest { killActor(follower1Actor); follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses( - ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id))). - config(followerConfigParams)); + ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id))) + .config(followerConfigParams)); follower1Actor.underlyingActor().waitForRecoveryComplete(); follower1Context = follower1Actor.underlyingActor().getRaftActorContext(); @@ -129,22 +127,22 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest { private void createRaftActors() { testLog.info("createRaftActors starting"); - follower1NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class), + follower1NotifierActor = factory.createActor(MessageCollectorActor.props(), factory.generateActorId(follower1Id + "-notifier")); followerConfigParams = newFollowerConfigParams(); followerConfigParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS)); followerConfigParams.setSnapshotBatchCount(snapshotBatchCount); follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses( - ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id))). - config(followerConfigParams).roleChangeNotifier(follower1NotifierActor)); + ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id))) + .config(followerConfigParams).roleChangeNotifier(follower1NotifierActor)); follower2Actor = newTestRaftActor(follower2Id, ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, testActorPath(follower1Id)), followerConfigParams); - peerAddresses = ImmutableMap.builder(). - put(follower1Id, follower1Actor.path().toString()). - put(follower2Id, follower2Actor.path().toString()).build(); + peerAddresses = ImmutableMap.builder() + .put(follower1Id, follower1Actor.path().toString()) + .put(follower2Id, follower2Actor.path().toString()).build(); leaderConfigParams = newLeaderConfigParams(); leaderConfigParams.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS)); @@ -158,6 +156,7 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest { waitUntilLeader(leaderActor); expectMatching(leaderCollectorActor, AppendEntriesReply.class, 2); + expectFirstMatching(follower1CollectorActor, AppendEntries.class); clearMessages(leaderCollectorActor); clearMessages(follower1CollectorActor); @@ -169,6 +168,6 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest { follower1Context = follower1Actor.underlyingActor().getRaftActorContext(); follower2Context = follower2Actor.underlyingActor().getRaftActorContext(); - testLog.info("createRaftActors ending"); + testLog.info("createRaftActors ending - follower1: {}, follower2: {}", follower1Id, follower2Id); } }