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=023f60909e0b3d41b044ebba3668f54144bc3ceb;hpb=fed267bf1b8a9ea81d1ee7c9721962863b98e391;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 023f60909e..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 @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.controller.cluster.raft; import static org.junit.Assert.assertArrayEquals; @@ -152,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);