From 1fcad0bba05ddb4474a1dd5bd59413ff38f2840f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 14 Aug 2017 18:03:51 +0200 Subject: [PATCH] Make ShardTest.testCommitWhenTransactionHasModifications() wait a bit 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 --- .../controller/cluster/datastore/AbstractShardTest.java | 5 ++++- .../opendaylight/controller/cluster/datastore/ShardTest.java | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java index e99710e2fc..6f7d8fb9df 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java @@ -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()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java index e84381f989..54183ae0ff 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java @@ -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); -- 2.36.6