Fix intermittent failure in ReplicationAndSnapshotsIntegrationTest 42/38242/3
authorTom Pantelis <tpanteli@brocade.com>
Fri, 29 Apr 2016 08:16:49 +0000 (04:16 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Mon, 2 May 2016 20:02:35 +0000 (20:02 +0000)
Verification of the follower's snapshot intermittently fails in
testFirstSnapshot. The problem is that the last applied term/index may
or may not reflect the last log index. The test doesn't expect it to and
most of the time it doesn't but it can, which is perfectly fine. So to
avoid intermittent failures I changed it to just verify the snapshot's
last log term/index which shoild be constant.

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

index 6334173cc6ff61d3041ab373b713d477d8cf4c88..e48234c0a3b5328244b1242971b6b96a41cc0c15 100644 (file)
@@ -233,10 +233,10 @@ public class ReplicationAndSnapshotsIntegrationTest extends AbstractRaftActorInt
         MessageCollectorActor.expectFirstMatching(follower1CollectorActor, SaveSnapshotSuccess.class);
         persistedSnapshots = InMemorySnapshotStore.getSnapshots(follower1Id, Snapshot.class);
         assertEquals("Persisted snapshots size", 1, persistedSnapshots.size());
-        verifySnapshot("Persisted", persistedSnapshots.get(0), initialTerm, 2, currentTerm, 3);
-        unAppliedEntry = persistedSnapshots.get(0).getUnAppliedEntries();
-        assertEquals("Persisted Snapshot getUnAppliedEntries size", 1, unAppliedEntry.size());
-        verifyReplicatedLogEntry(unAppliedEntry.get(0), currentTerm, 3, payload3);
+        // The last applied index in the snapshot may or may not be the last log entry depending on
+        // timing so to avoid intermittent test failures, we'll just verify the snapshot's last term/index.
+        assertEquals("Follower1 Snapshot getLastTerm", currentTerm, persistedSnapshots.get(0).getLastTerm());
+        assertEquals("Follower1 Snapshot getLastIndex", 3, persistedSnapshots.get(0).getLastIndex());
 
         MessageCollectorActor.expectFirstMatching(follower2CollectorActor, SaveSnapshotSuccess.class);