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%2FShardTransactionTest.java;h=b22001a4da6c234f6ac7b7167e4f4a4e18d25771;hb=c6c9b43923bbe8bc6d586ce09649324949e6b092;hp=c9335f378a8662e7b7ceb488961fb49588d50baf;hpb=dbff1740fe3e5a1f007c183ecc27d25915866945;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java index c9335f378a..b22001a4da 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java @@ -26,6 +26,7 @@ import org.opendaylight.controller.cluster.datastore.messages.BatchedModificatio import org.opendaylight.controller.cluster.datastore.messages.BatchedModificationsReply; import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction; import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply; +import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply; import org.opendaylight.controller.cluster.datastore.messages.CreateSnapshot; import org.opendaylight.controller.cluster.datastore.messages.DataExists; import org.opendaylight.controller.cluster.datastore.messages.DataExistsReply; @@ -412,11 +413,11 @@ public class ShardTransactionTest extends AbstractActorTest { } @Test - public void testOnReceiveBatchedModificationsReady() throws Exception { + public void testOnReceiveBatchedModificationsReadyWithoutImmediateCommit() throws Exception { new JavaTestKit(getSystem()) {{ final ActorRef transaction = newTransactionActor(store.newWriteOnlyTransaction(), - "testOnReceiveBatchedModificationsReady"); + "testOnReceiveBatchedModificationsReadyWithoutImmediateCommit"); JavaTestKit watcher = new JavaTestKit(getSystem()); watcher.watch(transaction); @@ -443,6 +444,33 @@ public class ShardTransactionTest extends AbstractActorTest { }}; } + @Test + public void testOnReceiveBatchedModificationsReadyWithImmediateCommit() throws Exception { + new JavaTestKit(getSystem()) {{ + + final ActorRef transaction = newTransactionActor(store.newWriteOnlyTransaction(), + "testOnReceiveBatchedModificationsReadyWithImmediateCommit"); + + JavaTestKit watcher = new JavaTestKit(getSystem()); + watcher.watch(transaction); + + YangInstanceIdentifier writePath = TestModel.TEST_PATH; + NormalizedNode writeData = ImmutableContainerNodeBuilder.create().withNodeIdentifier( + new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)). + withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build(); + + BatchedModifications batched = new BatchedModifications("tx1", DataStoreVersions.CURRENT_VERSION, null); + batched.addModification(new WriteModification(writePath, writeData)); + batched.setReady(true); + batched.setDoCommitOnReady(true); + batched.setTotalMessagesSent(1); + + transaction.tell(batched, getRef()); + expectMsgClass(duration("5 seconds"), CommitTransactionReply.SERIALIZABLE_CLASS); + watcher.expectMsgClass(duration("5 seconds"), Terminated.class); + }}; + } + @Test(expected=TestException.class) public void testOnReceiveBatchedModificationsFailure() throws Throwable { new JavaTestKit(getSystem()) {{