X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FSnapshotManagerTest.java;h=df83f8f55843b4f82ad9f4f8336c8b6913482c5b;hb=928f7af243a1e7ff9cf2b9b58846fa16a7009cca;hp=0078c2bd848d6677efd7c0d241e1c083c07807e4;hpb=22b54aa128163a52eb89743ce8d0d75615f6a04e;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotManagerTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotManagerTest.java index 0078c2bd84..df83f8f558 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotManagerTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotManagerTest.java @@ -160,6 +160,35 @@ public class SnapshotManagerTest extends AbstractActorTest { } + @Test + public void testCaptureWithNullLastLogEntry() throws Exception { + boolean capture = snapshotManager.capture(null, 1); + + assertTrue(capture); + + assertEquals(true, snapshotManager.isCapturing()); + + verify(mockProcedure).apply(null); + + CaptureSnapshot captureSnapshot = snapshotManager.getCaptureSnapshot(); + + System.out.println(captureSnapshot); + + // LastIndex and LastTerm are picked up from the lastLogEntry + assertEquals(-1L, captureSnapshot.getLastIndex()); + assertEquals(-1L, captureSnapshot.getLastTerm()); + + // Since the actor does not have any followers (no peer addresses) lastApplied will be from lastLogEntry + assertEquals(-1L, captureSnapshot.getLastAppliedIndex()); + assertEquals(-1L, captureSnapshot.getLastAppliedTerm()); + + // + assertEquals(-1L, captureSnapshot.getReplicatedToAllIndex()); + assertEquals(-1L, captureSnapshot.getReplicatedToAllTerm()); + actorRef.underlyingActor().clear(); + + } + @Test public void testCaptureWithCreateProcedureError () throws Exception { doThrow(new Exception("mock")).when(mockProcedure).apply(null);