Fix intermittent PreLeaderScenarioTest failure 75/58775/2
authorTom Pantelis <tompantelis@gmail.com>
Tue, 13 Jun 2017 00:28:06 +0000 (20:28 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Tue, 13 Jun 2017 15:09:36 +0000 (15:09 +0000)
java.lang.AssertionError: AppendEntries - # entries expected:<1> but was:<0>
  at org.junit.Assert.fail(Assert.java:88)
  at org.junit.Assert.failNotEquals(Assert.java:743)
  at org.junit.Assert.assertEquals(Assert.java:118)
  at org.junit.Assert.assertEquals(Assert.java:555)
  at org.opendaylight.controller.cluster.raft.PreLeaderScenarioTest.testUnComittedEntryOnLeaderChange(PreLeaderScenarioTest.java:57)

AppendEntries appendEntries = expectFirstMatching(follower1CollectorActor,
                AppendEntries.class);
assertEquals("AppendEntries - # entries", 1, appendEntries.getEntries().size());

After the payload is sent to the leader, it expects an AppendEntries sent to follower1
with a single ReplicatedLogEntry. From the test output this did occur correctly but
the MessageCollectorActor still had the initial empty AppendEntries sent on leader
startup. The test setup waits for the initial AppendEntriesReply's from both followers
prior to clearing messages in each MessageCollectorActor however the AppendEntries may
not have been delivered to follower1's MessageCollectorActor yet and thus doesn't get
cleared. We need to specifically wait for the AppendEntries in follower1's
MessageCollectorActor.

Change-Id: I638a21e75ea135c1fe24970135f564da4fc5738e
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/PreLeaderScenarioTest.java

index a1ada53..e4628d7 100644 (file)
@@ -159,6 +159,7 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest {
         waitUntilLeader(leaderActor);
 
         expectMatching(leaderCollectorActor, AppendEntriesReply.class, 2);
+        expectFirstMatching(follower1CollectorActor, AppendEntries.class);
 
         clearMessages(leaderCollectorActor);
         clearMessages(follower1CollectorActor);

©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.