X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fsharding%2FDistributedShardedDOMDataTreeRemotingTest.java;h=a4bda16f2004661edb950300d991058704737a4e;hb=72d71d1cded60bcac65296211272754006b3f89a;hp=ca8af73cb0d8087b7722652d8c3f800fa562cc57;hpb=2ab5805594a7507fa658d6cf93f72374701b582f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java index ca8af73cb0..a4bda16f20 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java @@ -21,7 +21,7 @@ import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.AddressFromURIString; import akka.cluster.Cluster; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.Lists; import com.typesafe.config.ConfigFactory; import java.util.Collections; @@ -30,7 +30,6 @@ import java.util.Set; import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; import org.opendaylight.controller.cluster.ActorSystemProvider; @@ -129,21 +128,25 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { followerOperDatastore.close(); } - JavaTestKit.shutdownActorSystem(leaderSystem, null, Boolean.TRUE); - JavaTestKit.shutdownActorSystem(followerSystem, null, Boolean.TRUE); + TestKit.shutdownActorSystem(leaderSystem, true); + TestKit.shutdownActorSystem(followerSystem, true); InMemoryJournal.clear(); InMemorySnapshotStore.clear(); } private void initEmptyDatastores() throws Exception { + initEmptyDatastores(MODULE_SHARDS_CONFIG); + } + + private void initEmptyDatastores(final String moduleShardsConfig) throws Exception { leaderTestKit = new IntegrationTestKit(leaderSystem, leaderDatastoreContextBuilder); leaderConfigDatastore = leaderTestKit.setupDistributedDataStore( - "config", MODULE_SHARDS_CONFIG, true, + "config", moduleShardsConfig, true, SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext()); leaderOperDatastore = leaderTestKit.setupDistributedDataStore( - "operational", MODULE_SHARDS_CONFIG, true, + "operational", moduleShardsConfig, true, SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext()); leaderShardFactory = new DistributedShardedDOMDataTree(leaderSystemProvider, @@ -153,9 +156,9 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { followerTestKit = new IntegrationTestKit(followerSystem, followerDatastoreContextBuilder); followerConfigDatastore = followerTestKit.setupDistributedDataStore( - "config", MODULE_SHARDS_CONFIG, true, SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext()); + "config", moduleShardsConfig, true, SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext()); followerOperDatastore = followerTestKit.setupDistributedDataStore( - "operational", MODULE_SHARDS_CONFIG, true, + "operational", moduleShardsConfig, true, SchemaContextHelper.distributedShardedDOMDataTreeSchemaContext()); followerShardFactory = new DistributedShardedDOMDataTree(followerSystemProvider, @@ -164,14 +167,17 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { followerTestKit.waitForMembersUp("member-1"); + LOG.info("Initializing leader DistributedShardedDOMDataTree"); leaderShardFactory.init(); - followerShardFactory.init(); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(YangInstanceIdentifier.EMPTY)); - leaderTestKit.waitUntilLeader(leaderOperDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderOperDatastore.getActorUtils(), ClusterUtils.getCleanShardName(YangInstanceIdentifier.EMPTY)); + + LOG.info("Initializing follower DistributedShardedDOMDataTree"); + followerShardFactory.init(); } @Test @@ -187,15 +193,15 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME, AbstractTest.MEMBER_2_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier())); - final ActorRef leaderShardManager = leaderConfigDatastore.getActorContext().getShardManager(); + final ActorRef leaderShardManager = leaderConfigDatastore.getActorUtils().getShardManager(); - assertNotNull(findLocalShard(leaderConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()))); - assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()))); final Set peers = new HashSet<>(); @@ -253,9 +259,9 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier())); - findLocalShard(followerConfigDatastore.getActorContext(), + findLocalShard(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier())); final Set peers = new HashSet<>(); @@ -279,7 +285,7 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { cursor.close(); LOG.warn("Got to pre submit"); - tx.submit().checkedGet(); + tx.commit().get(); shardRegistration.close().toCompletableFuture().get(); @@ -310,39 +316,39 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { Lists.newArrayList(AbstractTest.MEMBER_NAME, AbstractTest.MEMBER_2_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.OUTER_CONTAINER_PATH)); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.INNER_LIST_PATH)); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.JUNK_PATH)); // check leader has local shards - assertNotNull(findLocalShard(leaderConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); - assertNotNull(findLocalShard(leaderConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.OUTER_CONTAINER_PATH))); - assertNotNull(findLocalShard(leaderConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.INNER_LIST_PATH))); - assertNotNull(findLocalShard(leaderConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.JUNK_PATH))); // check follower has local shards - assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); - assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.OUTER_CONTAINER_PATH))); - assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.INNER_LIST_PATH))); - assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.JUNK_PATH))); LOG.debug("Closing registrations"); @@ -352,30 +358,30 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { reg3.close().toCompletableFuture().get(); reg4.close().toCompletableFuture().get(); - waitUntilShardIsDown(leaderConfigDatastore.getActorContext(), + waitUntilShardIsDown(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); - waitUntilShardIsDown(leaderConfigDatastore.getActorContext(), + waitUntilShardIsDown(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.OUTER_CONTAINER_PATH)); - waitUntilShardIsDown(leaderConfigDatastore.getActorContext(), + waitUntilShardIsDown(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.INNER_LIST_PATH)); - waitUntilShardIsDown(leaderConfigDatastore.getActorContext(), + waitUntilShardIsDown(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.JUNK_PATH)); LOG.debug("All leader shards gone"); - waitUntilShardIsDown(followerConfigDatastore.getActorContext(), + waitUntilShardIsDown(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); - waitUntilShardIsDown(followerConfigDatastore.getActorContext(), + waitUntilShardIsDown(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.OUTER_CONTAINER_PATH)); - waitUntilShardIsDown(followerConfigDatastore.getActorContext(), + waitUntilShardIsDown(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.INNER_LIST_PATH)); - waitUntilShardIsDown(followerConfigDatastore.getActorContext(), + waitUntilShardIsDown(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.JUNK_PATH)); LOG.debug("All follower shards gone"); @@ -383,24 +389,23 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { } @Test - @Ignore public void testMultipleRegistrationsAtOnePrefix() throws Exception { LOG.info("testMultipleRegistrationsAtOnePrefix starting"); initEmptyDatastores(); - for (int i = 0; i < 10; i++) { - LOG.debug("Round {}", i); + for (int i = 0; i < 5; i++) { + LOG.info("Round {}", i); final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard( TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME, AbstractTest.MEMBER_2_NAME)), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorContext(), + leaderTestKit.waitUntilLeader(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); - assertNotNull(findLocalShard(leaderConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); - assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), + assertNotNull(findLocalShard(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); @@ -412,13 +417,21 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); - waitUntilShardIsDown(leaderConfigDatastore.getActorContext(), + waitUntilShardIsDown(leaderConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); - waitUntilShardIsDown(followerConfigDatastore.getActorContext(), + waitUntilShardIsDown(followerConfigDatastore.getActorUtils(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); } LOG.info("testMultipleRegistrationsAtOnePrefix ending"); } + + @Test + public void testInitialBootstrappingWithNoModuleShards() throws Exception { + LOG.info("testInitialBootstrappingWithNoModuleShards starting"); + initEmptyDatastores("module-shards-default-member-1.conf"); + + // We just verify the DistributedShardedDOMDataTree initialized without error. + } }