Bug 2461 : Adding capture snapshot JMX operation.
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / SnapshotManagerTest.java
index 0078c2bd848d6677efd7c0d241e1c083c07807e4..df83f8f55843b4f82ad9f4f8336c8b6913482c5b 100644 (file)
@@ -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);