Make ShardTest.testCommitWhenTransactionHasModifications() wait a bit 03/61703/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 14 Aug 2017 16:03:51 +0000 (18:03 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 16 Aug 2017 18:01:13 +0000 (18:01 +0000)
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 e99710e2fc9edcfc3f0b86e50bc2a6074dce4f5b..6f7d8fb9df716fc474a3759e312be2816d1920ba 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 e84381f989e5946cea8de3ab18e545c937d989d8..54183ae0ff1b54160bfe4ceba639d6817b81b4d8 100644 (file)
@@ -1186,6 +1186,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);