use of org.neo4j.causalclustering.core.consensus.RaftMessages.Timeout.Election in project neo4j by neo4j.
the class FollowerTest method shouldBecomeCandidateOnReceivingElectionTimeoutMessage.
@Test
public void shouldBecomeCandidateOnReceivingElectionTimeoutMessage() throws Exception {
// given
RaftState state = raftState().myself(myself).votingMembers(asSet(myself, member1, member2)).build();
Follower follower = new Follower();
// when
Outcome outcome = follower.handle(new Election(myself), state, log());
// then
assertEquals(CANDIDATE, outcome.getRole());
}
use of org.neo4j.causalclustering.core.consensus.RaftMessages.Timeout.Election in project neo4j by neo4j.
the class OutOfOrderDeliveryTest method shouldReOrder.
@Test
public void shouldReOrder() throws Exception {
// given
ClusterState clusterState = new ClusterState(asSet(member(0)));
clusterState.queues.get(member(0)).add(new Election(member(0)));
clusterState.queues.get(member(0)).add(new Heartbeat(member(0)));
// when
ClusterState reOrdered = new OutOfOrderDelivery(member(0)).advance(clusterState);
// then
assertEquals(new Heartbeat(member(0)), reOrdered.queues.get(member(0)).poll());
assertEquals(new Election(member(0)), reOrdered.queues.get(member(0)).poll());
}
use of org.neo4j.causalclustering.core.consensus.RaftMessages.Timeout.Election in project neo4j by neo4j.
the class FollowerTest method followerShouldTransitToCandidateAndInstigateAnElectionAfterTimeout.
@Test
public void followerShouldTransitToCandidateAndInstigateAnElectionAfterTimeout() throws Exception {
// given
RaftState state = raftState().myself(myself).votingMembers(asSet(myself, member1, member2)).build();
// when
Outcome outcome = new Follower().handle(new Election(myself), state, log());
state.update(outcome);
// then
assertEquals(CANDIDATE, outcome.getRole());
assertNotNull(messageFor(outcome, member1));
assertNotNull(messageFor(outcome, member2));
}
Aggregations