import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.getAllMatching;
-import akka.actor.Actor;
import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.testkit.TestActorRef;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import java.util.List;
* @author Thomas Pantelis
*/
public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
- private TestActorRef<Actor> follower1NotifierActor;
- private TestActorRef<Actor> leaderNotifierActor;
+ private ActorRef follower1NotifierActor;
+ private ActorRef leaderNotifierActor;
/**
* Isolates the leader after all initial payload entries have been committed and applied on all nodes. While
* appropriately.
*/
@Test
- public void testLeaderIsolationWithAllPriorEntriesCommitted() throws Exception {
+ public void testLeaderIsolationWithAllPriorEntriesCommitted() {
testLog.info("testLeaderIsolationWithAllPriorEntriesCommitted starting");
createRaftActors();
* sides should reconcile their logs appropriately.
*/
@Test
- public void testLeaderIsolationWithPriorUncommittedEntryAndOneConflictingEntry() throws Exception {
+ public void testLeaderIsolationWithPriorUncommittedEntryAndOneConflictingEntry() {
testLog.info("testLeaderIsolationWithPriorUncommittedEntryAndOneConflictingEntry starting");
createRaftActors();
// Wait for the isolated leader to send AppendEntries to the followers with the new entry with index 1. This
// message is forwarded to the followers.
- expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
- return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
- && ae.getEntries().get(0).getData().equals(payload1);
- });
+ expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae ->
+ ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+ && ae.getEntries().get(0).getData().equals(payload1));
- expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
- return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
- && ae.getEntries().get(0).getData().equals(payload1);
- });
+ expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae ->
+ ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+ && ae.getEntries().get(0).getData().equals(payload1));
verifyApplyJournalEntries(leaderCollectorActor, 1);
* and both sides should reconcile their logs appropriately.
*/
@Test
- public void testLeaderIsolationWithPriorUncommittedEntryAndMultipleConflictingEntries() throws Exception {
+ public void testLeaderIsolationWithPriorUncommittedEntryAndMultipleConflictingEntries() {
testLog.info("testLeaderIsolationWithPriorUncommittedEntryAndMultipleConflictingEntries starting");
createRaftActors();
// Wait for the isolated leader to send AppendEntries to the followers with the new entry with index 1. This
// message is forwarded to the followers.
- expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
- return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
- && ae.getEntries().get(0).getData().equals(payload1);
- });
+ expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae ->
+ ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+ && ae.getEntries().get(0).getData().equals(payload1));
- expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
- return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
- && ae.getEntries().get(0).getData().equals(payload1);
- });
+ expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae ->
+ ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+ && ae.getEntries().get(0).getData().equals(payload1));
verifyApplyJournalEntries(leaderCollectorActor, 1);
private void createRaftActors() {
testLog.info("createRaftActors starting");
- follower1NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+ follower1NotifierActor = factory.createActor(MessageCollectorActor.props(),
factory.generateActorId(follower1Id + "-notifier"));
DefaultConfigParamsImpl followerConfigParams = new DefaultConfigParamsImpl();
leaderConfigParams = newLeaderConfigParams();
leaderConfigParams.setIsolatedLeaderCheckInterval(new FiniteDuration(500, TimeUnit.MILLISECONDS));
- leaderNotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+ leaderNotifierActor = factory.createActor(MessageCollectorActor.props(),
factory.generateActorId(leaderId + "-notifier"));
leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses)