From 6cfad84c01fee46df8a33a495d4f8bdc27caa3f0 Mon Sep 17 00:00:00 2001 From: Moiz Raja Date: Wed, 11 Feb 2015 11:53:08 -0800 Subject: [PATCH] Add a diagnostic message to figure out why test fails Adding a message to figure out why testFakeSnapshotsForLeaderWithInInitiateSnapshots fails sometimes Change-Id: I5c6f7d33e429a7497fa28ad99c316be2def59422 Signed-off-by: Moiz Raja --- .../cluster/raft/RaftActorTest.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java index cf7af439e5..9e0e06c70b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java @@ -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)); -- 2.36.6