X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fcompat%2FPreLithiumShardTest.java;h=1830523dcebe19b0c4aab98dece5572075e097de;hp=0631b1b1bf871944c1b3bee6947759879c52a8bd;hb=8e6e0aeb5ca474cb292aab6ca581e921b0a56489;hpb=8ec73bf853a9b6708b455c0321a585992e02b125 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java index 0631b1b1bf..1830523dce 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumShardTest.java @@ -12,30 +12,14 @@ import akka.actor.ActorRef; import akka.actor.PoisonPill; import akka.testkit.TestActorRef; import java.util.Collections; -import java.util.HashSet; -import java.util.Set; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.AbstractShardTest; -import org.opendaylight.controller.cluster.datastore.DataStoreVersions; import org.opendaylight.controller.cluster.datastore.Shard; -import org.opendaylight.controller.cluster.datastore.ShardTestKit; -import org.opendaylight.controller.cluster.datastore.modification.MergeModification; -import org.opendaylight.controller.cluster.datastore.modification.Modification; -import org.opendaylight.controller.cluster.datastore.modification.MutableCompositeModification; -import org.opendaylight.controller.cluster.datastore.modification.WriteModification; import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry; -import org.opendaylight.controller.cluster.raft.ReplicatedLogImplEntry; import org.opendaylight.controller.cluster.raft.Snapshot; -import org.opendaylight.controller.cluster.raft.base.messages.ApplyLogEntries; -import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; -import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationByteStringPayload; -import org.opendaylight.controller.cluster.raft.protobuff.client.messages.CompositeModificationPayload; -import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal; -import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; -import org.opendaylight.yangtools.util.StringIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; @@ -49,25 +33,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFac * @author Thomas Pantelis */ public class PreLithiumShardTest extends AbstractShardTest { - - private static CompositeModificationPayload newLegacyPayload(final Modification... mods) { - MutableCompositeModification compMod = new MutableCompositeModification(DataStoreVersions.HELIUM_2_VERSION); - for(Modification mod: mods) { - compMod.addModification(mod); - } - - return new CompositeModificationPayload(compMod.toSerializable()); - } - - private static CompositeModificationByteStringPayload newLegacyByteStringPayload(final Modification... mods) { - MutableCompositeModification compMod = new MutableCompositeModification(DataStoreVersions.HELIUM_2_VERSION); - for(Modification mod: mods) { - compMod.addModification(mod); - } - - return new CompositeModificationByteStringPayload(compMod.toSerializable()); - } - @Test public void testApplyHelium2VersionSnapshot() throws Exception { TestActorRef shard = TestActorRef.create(getSystem(), newShardProps(), @@ -96,82 +61,4 @@ public class PreLithiumShardTest extends AbstractShardTest { shard.tell(PoisonPill.getInstance(), ActorRef.noSender()); } - - @Test - public void testHelium2VersionApplyStateLegacy() throws Exception { - new ShardTestKit(getSystem()) {{ - TestActorRef shard = TestActorRef.create(getSystem(), newShardProps(), - "testHelium2VersionApplyStateLegacy"); - - waitUntilLeader(shard); - - NormalizedNode node = ImmutableNodes.containerNode(TestModel.TEST_QNAME); - - ApplyState applyState = new ApplyState(null, new StringIdentifier("test"), - new ReplicatedLogImplEntry(1, 2, - newLegacyByteStringPayload(new WriteModification(TestModel.TEST_PATH, node)))); - - shard.underlyingActor().onReceiveCommand(applyState); - - NormalizedNode actual = readStore(shard, TestModel.TEST_PATH); - assertEquals("Applied state", node, actual); - - shard.tell(PoisonPill.getInstance(), ActorRef.noSender()); - }}; - } - - @Test - public void testHelium2VersionRecovery() throws Exception { - - DataTree testStore = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL); - testStore.setSchemaContext(SCHEMA_CONTEXT); - - writeToStore(testStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - NormalizedNode root = readStore(testStore, YangInstanceIdentifier.builder().build()); - - InMemorySnapshotStore.addSnapshot(shardID.toString(), Snapshot.create( - new NormalizedNodeToNodeCodec(SCHEMA_CONTEXT).encode(root). - getNormalizedNode().toByteString().toByteArray(), - Collections.emptyList(), 0, 1, -1, -1)); - - InMemoryJournal.addEntry(shardID.toString(), 0, new String("Dummy data as snapshot sequence number is " + - "set to 0 in InMemorySnapshotStore and journal recovery seq number will start from 1")); - - // Set up the InMemoryJournal. - - InMemoryJournal.addEntry(shardID.toString(), 1, new ReplicatedLogImplEntry(0, 1, newLegacyPayload( - new WriteModification(TestModel.OUTER_LIST_PATH, - ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build())))); - - int nListEntries = 16; - Set listEntryKeys = new HashSet<>(); - int i = 1; - - // Add some CompositeModificationPayload entries - for(; i <= 8; i++) { - listEntryKeys.add(Integer.valueOf(i)); - YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH) - .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i).build(); - Modification mod = new MergeModification(path, - ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i)); - InMemoryJournal.addEntry(shardID.toString(), i+1, new ReplicatedLogImplEntry(i, 1, - newLegacyPayload(mod))); - } - - // Add some CompositeModificationByteStringPayload entries - for(; i <= nListEntries; i++) { - listEntryKeys.add(Integer.valueOf(i)); - YangInstanceIdentifier path = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH) - .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i).build(); - Modification mod = new MergeModification(path, - ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i)); - InMemoryJournal.addEntry(shardID.toString(), i+1, new ReplicatedLogImplEntry(i, 1, - newLegacyByteStringPayload(mod))); - } - - InMemoryJournal.addEntry(shardID.toString(), nListEntries + 2, new ApplyLogEntries(nListEntries)); - - testRecovery(listEntryKeys); - } }