From 8a01182f04388cbdfd33cad2578f8ce2b3978104 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Wed, 22 Apr 2015 06:54:07 -0400 Subject: [PATCH] Fix ShardTest#testCreateSnapshot unit test failures 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 --- .../opendaylight/controller/cluster/raft/SnapshotManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java index 847954816c..9a916625c9 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java @@ -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; } -- 2.36.6