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%2FShardRecoveryCoordinatorTest.java;h=b730150668fa3796eee6ed55c97553a27df74614;hb=204f45f8b3233dbea87e2c8065914f0d2a0ded07;hp=4778c569b4d9f55781cc337444469c9651ce9020;hpb=132578158b5b621b6ff372219fdfd4f8c5728885;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java index 4778c569b4..b730150668 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.cluster.datastore; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; - import com.google.common.base.Optional; import java.io.IOException; import org.junit.Before; @@ -30,6 +29,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree; +import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException; import org.opendaylight.yangtools.yang.model.api.SchemaContext; @@ -46,12 +46,13 @@ public class ShardRecoveryCoordinatorTest { peopleSchemaContext = SchemaContextHelper.select(SchemaContextHelper.PEOPLE_YANG); carsSchemaContext = SchemaContextHelper.select(SchemaContextHelper.CARS_YANG); - peopleDataTree = new ShardDataTree(peopleSchemaContext); + peopleDataTree = new ShardDataTree(peopleSchemaContext, TreeType.OPERATIONAL); } @Test public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){ - final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo")); + final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, + peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { coordinator.appendRecoveredLogEntry(DataTreeCandidatePayload.create(createCar())); @@ -64,7 +65,8 @@ public class ShardRecoveryCoordinatorTest { @Test public void testAppendRecoveredLogEntryModificationPayload() throws IOException { - final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo")); + final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, + peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { final MutableCompositeModification modification = new MutableCompositeModification((short) 1); @@ -77,7 +79,8 @@ public class ShardRecoveryCoordinatorTest { @Test public void testAppendRecoveredLogEntryCompositeModificationPayload() throws IOException { - final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo")); + final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, + peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { final MutableCompositeModification modification = new MutableCompositeModification((short) 1); @@ -90,7 +93,8 @@ public class ShardRecoveryCoordinatorTest { @Test public void testAppendRecoveredLogEntryCompositeModificationByteStringPayload() throws IOException { - final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo")); + final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, + peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { final MutableCompositeModification modification = new MutableCompositeModification((short) 1); @@ -105,7 +109,8 @@ public class ShardRecoveryCoordinatorTest { @Test public void testApplyRecoverySnapshot(){ - final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree , peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo")); + final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, + peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); coordinator.applyRecoverySnapshot(createSnapshot()); @@ -117,7 +122,8 @@ public class ShardRecoveryCoordinatorTest { @Test public void testApplyCurrentLogRecoveryBatch(){ - final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, peopleSchemaContext, "foobar", LoggerFactory.getLogger("foo")); + final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree, + peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo")); coordinator.startLogRecoveryBatch(10); try { @@ -128,7 +134,7 @@ public class ShardRecoveryCoordinatorTest { } private DataTreeCandidateTip createCar(){ - final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(); + final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); dataTree.setSchemaContext(carsSchemaContext); final DataTreeSnapshot snapshot = dataTree.takeSnapshot(); @@ -142,30 +148,22 @@ public class ShardRecoveryCoordinatorTest { private Optional> readCars(final ShardDataTree shardDataTree){ final TipProducingDataTree dataTree = shardDataTree.getDataTree(); + // FIXME: this should not be called here dataTree.setSchemaContext(peopleSchemaContext); - final DataTreeSnapshot snapshot = dataTree.takeSnapshot(); - - final DataTreeModification modification = snapshot.newModification(); - - return modification.readNode(CarsModel.BASE_PATH); + return shardDataTree.readNode(CarsModel.BASE_PATH); } private Optional> readPeople(final ShardDataTree shardDataTree){ final TipProducingDataTree dataTree = shardDataTree.getDataTree(); + // FIXME: this should not be called here dataTree.setSchemaContext(peopleSchemaContext); - final DataTreeSnapshot snapshot = dataTree.takeSnapshot(); - - final DataTreeModification modification = snapshot.newModification(); - - return modification.readNode(PeopleModel.BASE_PATH); + return shardDataTree.readNode(PeopleModel.BASE_PATH); } - - - private byte[] createSnapshot(){ - final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(); + private static byte[] createSnapshot(){ + final TipProducingDataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); dataTree.setSchemaContext(SchemaContextHelper.select(SchemaContextHelper.CARS_YANG, SchemaContextHelper.PEOPLE_YANG)); DataTreeSnapshot snapshot = dataTree.takeSnapshot();