Fix timing issue in testChangeToVotingWithNoLeader 47/53047/3
authorTom Pantelis <tpanteli@brocade.com>
Thu, 9 Mar 2017 05:00:12 +0000 (00:00 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 9 Mar 2017 11:39:22 +0000 (11:39 +0000)
commit88852df542314ff2cb6f3669f4a2e1018e664769
tree1fd2878cb282ce040a042b9347d3bd3ba6729c7b
parent5f8b40a13b88b2a183450c2b67401415da47511a
Fix timing issue in testChangeToVotingWithNoLeader

RaftActorServerConfigurationSupportTest#testChangeToVotingWithNoLeader
failed on jenkins:

  RaftActorServerConfigurationSupportTest.testChangeToVotingWithNoLeader:1213 getStatus expected:<OK> but was:<NO_LEADER>

In the following test code:

  MessageCollectorActor.clearMessages(node1Collector);

  long term = ...
  node1RaftActorRef.tell(new AppendEntries(...). ActorRef.noSender());

  // Wait for the ElectionTimeout to clear the leaderId...

  MessageCollectorActor.expectFirstMatching(node1Collector, ElectionTimeout.class)

It expects an ElectionTimeout message to occur after the AppendEntries tell
but it's possible for an ElectionTimeout message to occur in between
clearMessages and tell calls which leads to the subsequent NO_LEADER b/c the
leaderId wasn't cleared yet via a subsequent ElectionTimeout message.

The test expects the leaderId to be cleared after the AppendEntries tell so
I changed it to explicitly check for that. The fact that it's actually cleared
as a side effect of an ElectionTimeout message is an implementation detail
anyway.

Change-Id: I66eaad090d0e75fc3731e59f0a345cb04b4f2c4c
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java

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