From fc3e438ca11af37102c3e29e5ef38af85b9f286c Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Fri, 29 Apr 2016 04:16:49 -0400 Subject: [PATCH] Fix intermittent failure in ReplicationAndSnapshotsIntegrationTest 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 --- .../raft/ReplicationAndSnapshotsIntegrationTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsIntegrationTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsIntegrationTest.java index 6334173cc6..e48234c0a3 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsIntegrationTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsIntegrationTest.java @@ -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); -- 2.36.6