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%2FDistributedShardedDOMDataTreeTest.java;h=8faaf6ac0cca1a02567b6a44eac036907ec1fd8d;hb=refs%2Fchanges%2F99%2F56399%2F5;hp=41329641d165b9bf35683824bc80bb36d58d5b5a;hpb=1a6462c3cdb2cd310ab9503beb18da70f6e3779d;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java index 41329641d1..8faaf6ac0c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java @@ -10,6 +10,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.mockito.Matchers.anyCollection; import static org.mockito.Matchers.anyMap; import static org.mockito.Mockito.doNothing; @@ -55,6 +56,8 @@ import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder; import org.opendaylight.controller.cluster.datastore.DistributedDataStore; import org.opendaylight.controller.cluster.datastore.IntegrationTestKit; import org.opendaylight.controller.cluster.datastore.utils.ClusterUtils; +import org.opendaylight.controller.cluster.dom.api.CDSDataTreeProducer; +import org.opendaylight.controller.cluster.dom.api.CDSShardAccess; import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore; import org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration; @@ -335,8 +338,8 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { } // top level shard at TEST element, with subshards on each outer-list map entry - @Ignore("https://bugs.opendaylight.org/show_bug.cgi?id=8116") @Test + @Ignore public void testMultipleShardLevels() throws Exception { initEmptyDatastores(); @@ -397,8 +400,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { leaderShardFactory.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID), true, Collections.emptyList()); - // need 6 invocations, first initial thats from the parent shard, and then each individual subshard - verify(mockedDataTreeListener, timeout(20000).times(6)).onDataTreeChanged(captorForChanges.capture(), + verify(mockedDataTreeListener, timeout(35000).atLeast(2)).onDataTreeChanged(captorForChanges.capture(), captorForSubtrees.capture()); verifyNoMoreInteractions(mockedDataTreeListener); final List>> allSubtrees = captorForSubtrees.getAllValues(); @@ -448,6 +450,40 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { } } + @Test + public void testCDSDataTreeProducer() throws Exception { + initEmptyDatastores(); + + final DistributedShardRegistration reg1 = waitOnAsyncTask(leaderShardFactory.createDistributedShard( + TEST_ID, Lists.newArrayList(AbstractTest.MEMBER_NAME)), + DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); + + leaderTestKit.waitUntilLeader(leaderDistributedDataStore.getActorContext(), + ClusterUtils.getCleanShardName(TestModel.TEST_PATH)); + + assertNotNull(findLocalShard(leaderDistributedDataStore.getActorContext(), + ClusterUtils.getCleanShardName(TestModel.TEST_PATH))); + + + final DOMDataTreeIdentifier configRoot = + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY); + final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(configRoot)); + + assertTrue(producer instanceof CDSDataTreeProducer); + + final CDSDataTreeProducer cdsProducer = (CDSDataTreeProducer) producer; + CDSShardAccess shardAccess = cdsProducer.getShardAccess(TEST_ID); + assertEquals(shardAccess.getShardIdentifier(), TEST_ID); + + shardAccess = cdsProducer.getShardAccess(INNER_LIST_ID); + assertEquals(TEST_ID, shardAccess.getShardIdentifier()); + + shardAccess = cdsProducer.getShardAccess(configRoot); + assertEquals(configRoot, shardAccess.getShardIdentifier()); + + waitOnAsyncTask(reg1.close(), DistributedShardedDOMDataTree.SHARD_FUTURE_TIMEOUT_DURATION); + } + private static Collection createOuterEntries(final int amount, final String valuePrefix) { final Collection ret = new ArrayList<>(); for (int i = 0; i < amount; i++) {