Make ShardTest.testCommitWhenTransactionHasModifications() wait a bit 26/61626/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 14 Aug 2017 16:03:51 +0000 (18:03 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 14 Aug 2017 16:03:51 +0000 (18:03 +0200)
Committed transactions involve also a purge payload, which is persisted
asynchronously, hence it may or may not be visible in the journal just
after the transaction is reported as committed. Wait for two heartbeat
intervals before looking at the stats.

Change-Id: Ibe699edced12d006bf5ea8cd99aa821ab56d115d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java

index 59a8ecd9728252e53a27f287c75728cfc1e65c0a..b2872be9bdabc7630f2cca3cc55d0d1298c5bcb7 100644 (file)
@@ -95,11 +95,14 @@ public abstract class AbstractShardTest extends AbstractActorTest {
 
     private static final AtomicInteger NEXT_SHARD_NUM = new AtomicInteger();
 
+    protected static final int HEARTBEAT_MILLIS = 100;
+
     protected final ShardIdentifier shardID = ShardIdentifier.create("inventory", MemberName.forName("member-1"),
         "config" + NEXT_SHARD_NUM.getAndIncrement());
 
     protected final Builder dataStoreContextBuilder = DatastoreContext.newBuilder()
-            .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000).shardHeartbeatIntervalInMillis(100);
+            .shardJournalRecoveryLogBatchSize(3).shardSnapshotBatchCount(5000)
+            .shardHeartbeatIntervalInMillis(HEARTBEAT_MILLIS);
 
     protected final TestActorFactory actorFactory = new TestActorFactory(getSystem());
 
index 0c2a85e4237e7bcc27b158024c270c034ae7d769..6907d756e26b4c94ce38cf19ffafe6f58ae2241c 100644 (file)
@@ -1192,6 +1192,10 @@ public class ShardTest extends AbstractShardTest {
                 inOrder.verify(dataTree).prepare(any(DataTreeModification.class));
                 inOrder.verify(dataTree).commit(any(DataTreeCandidate.class));
 
+                // Purge request is scheduled as asynchronous, wait for two heartbeats to let it propagate into
+                // the journal
+                Thread.sleep(HEARTBEAT_MILLIS * 2);
+
                 shard.tell(Shard.GET_SHARD_MBEAN_MESSAGE, getRef());
                 final ShardStats shardStats = expectMsgClass(duration, ShardStats.class);