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%2Fdatastore%2FDatastoreContextIntrospectorTest.java;h=2bd2e61296daec3f41d9264b78d8652d3159c762;hb=e970feb618c5e3793454f7f1a3974797a61c7c17;hp=f2857f515e5535c453c162441d4b7b9cd03b777c;hpb=5105751d47439e5d71d3a3b8035e4afd262c1890;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java index f2857f515e..2bd2e61296 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java @@ -185,4 +185,49 @@ public class DatastoreContextIntrospectorTest { assertEquals(false, configContext.isPersistent()); assertEquals(444, configContext.getDataStoreProperties().getMaxDataChangeExecutorPoolSize()); } + + @Test + public void testGetDatastoreContextForShard() { + Dictionary properties = new Hashtable<>(); + properties.put("shard-transaction-idle-timeout-in-minutes", "22"); // global setting + properties.put("operational.shard-transaction-idle-timeout-in-minutes", "33"); // operational override + properties.put("config.shard-transaction-idle-timeout-in-minutes", "44"); // config override + properties.put("topology.shard-transaction-idle-timeout-in-minutes", "55"); // global shard override + + DatastoreContext operContext = DatastoreContext.newBuilder().dataStoreType("operational").build(); + DatastoreContextIntrospector operIntrospector = new DatastoreContextIntrospector(operContext); + + DatastoreContext shardContext = operIntrospector.newContextFactory().getShardDatastoreContext("topology"); + assertEquals(10, shardContext.getShardTransactionIdleTimeout().toMinutes()); + + operIntrospector.update(properties); + operContext = operIntrospector.getContext(); + assertEquals(33, operContext.getShardTransactionIdleTimeout().toMinutes()); + + shardContext = operIntrospector.newContextFactory().getShardDatastoreContext("topology"); + assertEquals(55, shardContext.getShardTransactionIdleTimeout().toMinutes()); + + DatastoreContext configContext = DatastoreContext.newBuilder().dataStoreType("config").build(); + DatastoreContextIntrospector configIntrospector = new DatastoreContextIntrospector(configContext); + configIntrospector.update(properties); + configContext = configIntrospector.getContext(); + assertEquals(44, configContext.getShardTransactionIdleTimeout().toMinutes()); + + shardContext = configIntrospector.newContextFactory().getShardDatastoreContext("topology"); + assertEquals(55, shardContext.getShardTransactionIdleTimeout().toMinutes()); + + properties.put("operational.topology.shard-transaction-idle-timeout-in-minutes", "66"); // operational shard override + properties.put("config.topology.shard-transaction-idle-timeout-in-minutes", "77"); // config shard override + + operIntrospector.update(properties); + shardContext = operIntrospector.newContextFactory().getShardDatastoreContext("topology"); + assertEquals(66, shardContext.getShardTransactionIdleTimeout().toMinutes()); + + configIntrospector.update(properties); + shardContext = configIntrospector.newContextFactory().getShardDatastoreContext("topology"); + assertEquals(77, shardContext.getShardTransactionIdleTimeout().toMinutes()); + + shardContext = configIntrospector.newContextFactory().getShardDatastoreContext("default"); + assertEquals(44, shardContext.getShardTransactionIdleTimeout().toMinutes()); + } }