X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FIntegrationTestKit.java;h=e205950f34103dfea2bbbc3e6684301f57249ad4;hb=abaef4a5ae37f27542155457fe7306a4662b1eeb;hp=b483be873ff3da98e3da85e5ea320623c5adaa45;hpb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6;p=controller.git 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 b483be873f..e205950f34 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 @@ -29,11 +29,11 @@ import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import org.mockito.Mockito; +import org.opendaylight.controller.cluster.databroker.ClientBackedDataStore; import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder; import org.opendaylight.controller.cluster.datastore.config.Configuration; import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl; import org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider; -import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats; import org.opendaylight.controller.cluster.datastore.messages.OnDemandShardState; import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot; import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; @@ -46,7 +46,7 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Await; @@ -78,14 +78,14 @@ public class IntegrationTestKit extends ShardTestKit { public DistributedDataStore setupDistributedDataStore(final String typeName, final String moduleShardsConfig, final boolean waitUntilLeader, - final SchemaContext schemaContext) throws Exception { + final EffectiveModelContext schemaContext) throws Exception { return setupDistributedDataStore(typeName, moduleShardsConfig, "modules.conf", waitUntilLeader, schemaContext); } public DistributedDataStore setupDistributedDataStore(final String typeName, final String moduleShardsConfig, final String modulesConfig, final boolean waitUntilLeader, - final SchemaContext schemaContext, + final EffectiveModelContext schemaContext, final String... shardNames) throws Exception { return (DistributedDataStore) setupAbstractDataStore(DistributedDataStore.class, typeName, moduleShardsConfig, modulesConfig, waitUntilLeader, schemaContext, shardNames); @@ -116,7 +116,7 @@ public class IntegrationTestKit extends ShardTestKit { public AbstractDataStore setupAbstractDataStore(final Class implementation, final String typeName, final String moduleShardsConfig, final boolean waitUntilLeader, - final SchemaContext schemaContext, + final EffectiveModelContext schemaContext, final String... shardNames) throws Exception { return setupAbstractDataStore(implementation, typeName, moduleShardsConfig, "modules.conf", waitUntilLeader, schemaContext, shardNames); @@ -125,13 +125,17 @@ public class IntegrationTestKit extends ShardTestKit { private AbstractDataStore setupAbstractDataStore(final Class implementation, final String typeName, final String moduleShardsConfig, final String modulesConfig, final boolean waitUntilLeader, - final SchemaContext schemaContext, final String... shardNames) + final EffectiveModelContext schemaContext, + final String... shardNames) throws Exception { final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem()); final Configuration config = new ConfigurationImpl(moduleShardsConfig, modulesConfig); setDataStoreName(typeName); + // Make sure we set up datastore context correctly + datastoreContextBuilder.useTellBasedProtocol(ClientBackedDataStore.class.isAssignableFrom(implementation)); + final DatastoreContext datastoreContext = datastoreContextBuilder.build(); final DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class); Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext(); @@ -144,7 +148,7 @@ public class IntegrationTestKit extends ShardTestKit { final AbstractDataStore dataStore = constructor.newInstance(getSystem(), cluster, config, mockContextFactory, restoreFromSnapshot); - dataStore.onGlobalContextUpdated(schemaContext); + dataStore.onModelContextUpdated(schemaContext); if (waitUntilLeader) { waitUntilLeader(dataStore.getActorUtils(), shardNames); @@ -165,7 +169,7 @@ public class IntegrationTestKit extends ShardTestKit { } public DistributedDataStore setupDistributedDataStoreWithoutConfig(final String typeName, - final SchemaContext schemaContext) { + final EffectiveModelContext schemaContext) { final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem()); final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider()); @@ -180,14 +184,14 @@ public class IntegrationTestKit extends ShardTestKit { final DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster, configuration, mockContextFactory, restoreFromSnapshot); - dataStore.onGlobalContextUpdated(schemaContext); + dataStore.onModelContextUpdated(schemaContext); datastoreContextBuilder = DatastoreContext.newBuilderFrom(datastoreContext); return dataStore; } public DistributedDataStore setupDistributedDataStoreWithoutConfig(final String typeName, - final SchemaContext schemaContext, + final EffectiveModelContext schemaContext, final LogicalDatastoreType storeType) { final ClusterWrapper cluster = new ClusterWrapperImpl(getSystem()); final ConfigurationImpl configuration = new ConfigurationImpl(new EmptyModuleShardConfigProvider()); @@ -204,7 +208,7 @@ public class IntegrationTestKit extends ShardTestKit { final DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster, configuration, mockContextFactory, restoreFromSnapshot); - dataStore.onGlobalContextUpdated(schemaContext); + dataStore.onModelContextUpdated(schemaContext); datastoreContextBuilder = DatastoreContext.newBuilderFrom(datastoreContext); return dataStore; @@ -251,7 +255,7 @@ public class IntegrationTestKit extends ShardTestKit { ActorRef shard = null; for (int i = 0; i < 20 * 5 && shard == null; i++) { Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); - com.google.common.base.Optional shardReply = actorUtils.findLocalShard(shardName); + Optional shardReply = actorUtils.findLocalShard(shardName); if (shardReply.isPresent()) { shard = shardReply.get(); } @@ -263,7 +267,7 @@ public class IntegrationTestKit extends ShardTestKit { for (int i = 0; i < 20 * 5 ; i++) { LOG.debug("Waiting for shard down {}", shardName); Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); - com.google.common.base.Optional shardReply = actorUtils.findLocalShard(shardName); + Optional shardReply = actorUtils.findLocalShard(shardName); if (!shardReply.isPresent()) { return; } @@ -323,7 +327,7 @@ public class IntegrationTestKit extends ShardTestKit { } void testWriteTransaction(final AbstractDataStore dataStore, final YangInstanceIdentifier nodePath, - final NormalizedNode nodeToWrite) throws Exception { + final NormalizedNode nodeToWrite) throws Exception { // 1. Create a write-only Tx @@ -346,7 +350,7 @@ public class IntegrationTestKit extends ShardTestKit { DOMStoreReadTransaction readTx = dataStore.newReadOnlyTransaction(); - Optional> optional = readTx.read(nodePath).get(5, TimeUnit.SECONDS); + Optional optional = readTx.read(nodePath).get(5, TimeUnit.SECONDS); assertTrue("isPresent", optional.isPresent()); assertEquals("Data node", nodeToWrite, optional.get()); }