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=af07d62d9cf44ec713ba3bf9bbca6d6cb4dfbc9f;hb=bd8ae452ab45390645d48e0967156c96ce70a2b9;hp=36a533e67be8a2a41f2f9c18acb4e0bdcc58238a;hpb=b7cedcc1c346813f71a56eebb0e4abe9e6828ee6;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 36a533e67b..af07d62d9c 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 @@ -8,6 +8,7 @@ package org.opendaylight.controller.cluster.sharding; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -24,6 +25,8 @@ import akka.testkit.JavaTestKit; import com.google.common.collect.Lists; import com.typesafe.config.ConfigFactory; import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -63,7 +66,7 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { private static final DOMDataTreeIdentifier TEST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH); - private static final String MODULE_SHARDS_CONFIG = "module-shards-cars-member-1-and-2.conf"; + private static final String MODULE_SHARDS_CONFIG = "module-shards-default.conf"; private ActorSystem leaderSystem; private ActorSystem followerSystem; @@ -168,15 +171,16 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { leaderTestKit.waitUntilLeader(leaderOperDatastore.getActorContext(), ClusterUtils.getCleanShardName(YangInstanceIdentifier.EMPTY)); - } @Test public void testProducerRegistrations() throws Exception { + LOG.info("testProducerRegistrations starting"); initEmptyDatastores(); leaderTestKit.waitForMembersUp("member-2"); + // TODO refactor shard creation and verification to own method final DistributedShardRegistration shardRegistration = waitOnAsyncTask(leaderShardFactory.createDistributedShard( TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME, AbstractTest.MEMBER_2_NAME)), @@ -193,6 +197,12 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()))); + final Set peers = new HashSet<>(); + IntegrationTestKit.verifyShardState(leaderConfigDatastore, + ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()), onDemandShardState -> + peers.addAll(onDemandShardState.getPeerAddresses().values())); + assertEquals(peers.size(), 1); + final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(TEST_ID)); try { followerShardFactory.createProducer(Collections.singleton(TEST_ID)); @@ -224,10 +234,13 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { } shardRegistration.close().toCompletableFuture().get(); + + LOG.info("testProducerRegistrations ending"); } @Test public void testWriteIntoMultipleShards() throws Exception { + LOG.info("testWriteIntoMultipleShards starting"); initEmptyDatastores(); leaderTestKit.waitForMembersUp("member-2"); @@ -244,6 +257,12 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { findLocalShard(followerConfigDatastore.getActorContext(), ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier())); + final Set peers = new HashSet<>(); + IntegrationTestKit.verifyShardState(leaderConfigDatastore, + ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()), onDemandShardState -> + peers.addAll(onDemandShardState.getPeerAddresses().values())); + assertEquals(peers.size(), 1); + LOG.debug("Got after waiting for nonleader"); final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(TEST_ID)); @@ -262,10 +281,13 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { tx.submit().checkedGet(); shardRegistration.close().toCompletableFuture().get(); + + LOG.info("testWriteIntoMultipleShards ending"); } @Test public void testMultipleShardRegistrations() throws Exception { + LOG.info("testMultipleShardRegistrations starting"); initEmptyDatastores(); final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard( @@ -322,7 +344,6 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), ClusterUtils.getCleanShardName(TestModel.JUNK_PATH))); - LOG.debug("Closing registrations"); reg1.close().toCompletableFuture().get(); @@ -357,14 +378,16 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { ClusterUtils.getCleanShardName(TestModel.JUNK_PATH)); LOG.debug("All follower shards gone"); + LOG.info("testMultipleShardRegistrations ending"); } @Test 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); @@ -378,6 +401,13 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { assertNotNull(findLocalShard(followerConfigDatastore.getActorContext(), ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); + + final Set peers = new HashSet<>(); + IntegrationTestKit.verifyShardState(leaderConfigDatastore, + ClusterUtils.getCleanShardName(TEST_ID.getRootIdentifier()), onDemandShardState -> + peers.addAll(onDemandShardState.getPeerAddresses().values())); + assertEquals(peers.size(), 1); + waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); waitUntilShardIsDown(leaderConfigDatastore.getActorContext(), @@ -387,5 +417,6 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); } + LOG.info("testMultipleRegistrationsAtOnePrefix ending"); } }