Fix ShardTest#testCreateSnapshot unit test failures 79/18879/4
authorTom Pantelis <tpanteli@brocade.com>
Wed, 22 Apr 2015 10:54:07 +0000 (06:54 -0400)
committerTony Tkacik <ttkacik@cisco.com>
Thu, 23 Apr 2015 09:42:01 +0000 (09:42 +0000)
This unit test is failing on jenkins quite often due to a timing issue
with the tests resulting from recent changes. Basically akka uses a
calling thread dispatcher by default so the call to
createSnapshotProcedure in the SnapshotManager may result in a direct
call to persist which fails b/c it's still in the Idle state. Moving the
setting of currentState to CREATING prior to calling
createSnapshotProcedure fixes the issue.

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

index 847954816ccd33f1c916ead7641b57200e2303e2..9a916625c9331413685d6263bfe053930b6795bf 100644 (file)
@@ -201,14 +201,16 @@ public class SnapshotManager implements SnapshotState {
 
             LOG.debug("lastSequenceNumber prior to capture: {}", lastSequenceNumber);
 
+            SnapshotManager.this.currentState = CREATING;
+
             try {
                 createSnapshotProcedure.apply(null);
             } catch (Exception e) {
+                SnapshotManager.this.currentState = IDLE;
                 LOG.error("Error creating snapshot", e);
                 return false;
             }
 
-            SnapshotManager.this.currentState = CREATING;
             return true;
         }