Fix intermittent RaftActorTest failures 82/20682/1
authorTom Pantelis <tpanteli@brocade.com>
Fri, 15 May 2015 01:28:14 +0000 (21:28 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Mon, 18 May 2015 23:29:54 +0000 (23:29 +0000)
I've seen the following test failure on jenkins several times:

  RaftActorTest.testRealSnapshotWhenReplicatedToAllIndexNotInReplicatedLog:838
expected:<Leader> but was:<Candidate>

This is a result of the short-circuiting of the election timeout scheduling
when there are no peers so it goes from from Follower -> Candidate -> Leader
quickly. The test artificially sets the behavior to Leader but the immediate
ElectionTimeout messages may cause it to switch back to Candidate and
cause assertion failures before the test completes. This didn't happen
before b/c it sets the heartbeat interval really high. To alleviate the
failures, I set a peer to elide the short-circuiting.

Change-Id: I2c086f214baefb826beb898dfe4b11b659cd1eaa
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
(cherry picked from commit 2f2dd5376f885a160d3204a407f24e174375a5a5)

opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java

index cca9a25..45c2e0d 100644 (file)
@@ -797,7 +797,7 @@ public class RaftActorTest extends AbstractActorTest {
 
             DataPersistenceProvider dataPersistenceProvider = new NonPersistentDataProvider();
 
-            Map<String, String> peerAddresses = new HashMap<>();
+            Map<String, String> peerAddresses = ImmutableMap.<String, String>builder().put("member1", "address").build();
 
             TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
                     MockRaftActor.props(persistenceId, peerAddresses,
@@ -844,7 +844,7 @@ public class RaftActorTest extends AbstractActorTest {
 
             DataPersistenceProvider dataPersistenceProvider = new NonPersistentDataProvider();
 
-            Map<String, String> peerAddresses = new HashMap<>();
+            Map<String, String> peerAddresses = ImmutableMap.<String, String>builder().put("member1", "address").build();
 
             TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
                     MockRaftActor.props(persistenceId, peerAddresses,

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.