Fix RaftActorTest.testRaftRoleChangeNotifier failure 47/15047/3
authortpantelis <tpanteli@brocade.com>
Fri, 20 Feb 2015 06:47:58 +0000 (01:47 -0500)
committertpantelis <tpanteli@brocade.com>
Fri, 20 Feb 2015 08:13:42 +0000 (03:13 -0500)
commitb2ea24f316dfc8f4c278bdb8910727241a691f3b
tree660044a40c71a426beec0d0ce6d6a0d480113bf9
parentea3673e89598b896c93ebee864e6cb8db7f6c6ec
Fix RaftActorTest.testRaftRoleChangeNotifier failure

I saw this test fail once:

   java.lang.AssertionError: expected:<3> but was:<2>
        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.junit.Assert.assertEquals(Assert.java:542)
        at
org.opendaylight.controller.cluster.raft.RaftActorTest$13.<init>(RaftActorTest.java:894)
        at
org.opendaylight.controller.cluster.raft.RaftActorTest.testRaftRoleChangeNotifier(RaftActorTest.java:881)

The test has an arbitrary 2 sec wait before retrieving the collected
RoleChanged messages. With the election timeout and arbitrary GC and threading
delays, 2 sec may not be enough.

Arbitrary sleeps in tests are usually trouble - I made it deterministic
by waiting 5 sec for the expected messages.

Change-Id: I51c24a5844321bbd000a0460777d08b51a5f82c8
Signed-off-by: tpantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java