X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FIntegrationTestKit.java;h=53e43f817d2f996b358c5756ac3fca1147bb2604;hp=94f20856ff43754dae02986b554259c9e637c212;hb=340a2d4c979ac6f8d5adff8bd9e1c9f724e7a164;hpb=103ceecd0195cca6c87fbd62a687d8addf128784 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java index 94f20856ff..53e43f817d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java @@ -72,14 +72,7 @@ class IntegrationTestKit extends ShardTestKit { void waitUntilLeader(ActorContext actorContext, String... shardNames) { for(String shardName: shardNames) { - ActorRef shard = null; - for(int i = 0; i < 20 * 5 && shard == null; i++) { - Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); - Optional shardReply = actorContext.findLocalShard(shardName); - if(shardReply.isPresent()) { - shard = shardReply.get(); - } - } + ActorRef shard = findLocalShard(actorContext, shardName); assertNotNull("Shard was not created", shard); @@ -87,6 +80,27 @@ class IntegrationTestKit extends ShardTestKit { } } + void waitUntilNoLeader(ActorContext actorContext, String... shardNames) { + for(String shardName: shardNames) { + ActorRef shard = findLocalShard(actorContext, shardName); + assertNotNull("No local shard found", shard); + + waitUntilNoLeader(shard); + } + } + + private ActorRef findLocalShard(ActorContext actorContext, String shardName) { + ActorRef shard = null; + for(int i = 0; i < 20 * 5 && shard == null; i++) { + Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); + Optional shardReply = actorContext.findLocalShard(shardName); + if(shardReply.isPresent()) { + shard = shardReply.get(); + } + } + return shard; + } + void testWriteTransaction(DistributedDataStore dataStore, YangInstanceIdentifier nodePath, NormalizedNode nodeToWrite) throws Exception {