use of org.opendaylight.controller.cluster.raft.messages.RequestVote in project controller by opendaylight.
the class CandidateTest method testResponseToRequestVoteWithLowerTerm.
@Test
public void testResponseToRequestVoteWithLowerTerm() {
candidate = new Candidate(createActorContext());
setupPeers(1);
candidate.handleMessage(peerActors[0], new RequestVote(1, "test", 0, 0));
RequestVoteReply reply = MessageCollectorActor.expectFirstMatching(peerActors[0], RequestVoteReply.class);
assertEquals("isVoteGranted", false, reply.isVoteGranted());
assertEquals("getTerm", 2, reply.getTerm());
}
use of org.opendaylight.controller.cluster.raft.messages.RequestVote in project controller by opendaylight.
the class ShardTest method testRegisterRoleChangeListener.
@Test
public void testRegisterRoleChangeListener() throws Exception {
new ShardTestKit(getSystem()) {
{
final TestActorRef<Shard> shard = actorFactory.createTestActor(newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()), "testRegisterRoleChangeListener");
waitUntilLeader(shard);
final ActorRef listener = getSystem().actorOf(MessageCollectorActor.props());
shard.tell(new RegisterRoleChangeListener(), listener);
MessageCollectorActor.expectFirstMatching(listener, RegisterRoleChangeListenerReply.class);
ShardLeaderStateChanged leaderStateChanged = MessageCollectorActor.expectFirstMatching(listener, ShardLeaderStateChanged.class);
assertEquals("getLocalShardDataTree present", true, leaderStateChanged.getLocalShardDataTree().isPresent());
assertSame("getLocalShardDataTree", shard.underlyingActor().getDataStore().getDataTree(), leaderStateChanged.getLocalShardDataTree().get());
MessageCollectorActor.clearMessages(listener);
// Force a leader change
shard.tell(new RequestVote(10000, "member2", 50, 50), getRef());
leaderStateChanged = MessageCollectorActor.expectFirstMatching(listener, ShardLeaderStateChanged.class);
assertEquals("getLocalShardDataTree present", false, leaderStateChanged.getLocalShardDataTree().isPresent());
}
};
}
Aggregations