Add a diagnostic message to figure out why test fails 61/15161/1
authorMoiz Raja <moraja@cisco.com>
Wed, 11 Feb 2015 19:53:08 +0000 (11:53 -0800)
committerMoiz Raja <moraja@cisco.com>
Wed, 11 Feb 2015 19:53:08 +0000 (11:53 -0800)
Adding a message to figure out why testFakeSnapshotsForLeaderWithInInitiateSnapshots
fails sometimes

Change-Id: I5c6f7d33e429a7497fa28ad99c316be2def59422
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java

index cf7af43..9e0e06c 100644 (file)
@@ -1,5 +1,18 @@
 package org.opendaylight.controller.cluster.raft;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.PoisonPill;
@@ -62,20 +75,6 @@ import scala.concurrent.Future;
 import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
 public class RaftActorTest extends AbstractActorTest {
 
 
@@ -1173,7 +1172,10 @@ public class RaftActorTest extends AbstractActorTest {
                 // simulate a real snapshot
                 leaderActor.onReceiveCommand(new InitiateInstallSnapshot());
                 assertEquals(5, leaderActor.getReplicatedLog().size());
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+                assertEquals(String.format("expected to be Leader but was %s. Current Leader = %s ",
+                        leaderActor.getCurrentBehavior().state(),leaderActor.getLeaderId())
+                        , RaftState.Leader, leaderActor.getCurrentBehavior().state());
+
 
                 //reply from a slow follower does not initiate a fake snapshot
                 leaderActor.onReceiveCommand(new AppendEntriesReply("follower-2", 1, true, 9, 1));