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%2FShardTransactionFailureTest.java;h=dae71b96cc7181e755f6ff7abcab4762cbcaddec;hb=4f1f2ae598588f6aa5aac59b2206d97ad402a193;hp=3ecc8c9902d0a65fd02f7dfb144dd4d830322ea3;hpb=80f668c77ef358ba5fbc53b0332597bd2c4844c2;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java index 3ecc8c9902..dae71b96cc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java @@ -13,6 +13,8 @@ import akka.actor.Props; import akka.testkit.TestActorRef; import java.util.concurrent.TimeUnit; import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats; import org.opendaylight.controller.cluster.datastore.messages.DataExists; @@ -38,11 +40,12 @@ public class ShardTransactionFailureTest extends AbstractActorTest { private static final TransactionType RW = TransactionType.READ_WRITE; private static final TransactionType WO = TransactionType.WRITE_ONLY; - private static final ShardDataTree store = new ShardDataTree(testSchemaContext, TreeType.OPERATIONAL); + private static final Shard mockShard = Mockito.mock(Shard.class); + + private static final ShardDataTree store = new ShardDataTree(mockShard, testSchemaContext, TreeType.OPERATIONAL); private static final ShardIdentifier SHARD_IDENTIFIER = - ShardIdentifier.builder().memberName("member-1") - .shardName("inventory").type("operational").build(); + ShardIdentifier.create("inventory", MemberName.forName("member-1"), "operational"); private final DatastoreContext datastoreContext = DatastoreContext.newBuilder().build(); @@ -59,19 +62,20 @@ public class ShardTransactionFailureTest extends AbstractActorTest { public void testNegativeReadWithReadOnlyTransactionClosed() throws Throwable { final ActorRef shard = createShard(); - final Props props = ShardTransaction.props(RO, store.newReadOnlyTransaction("test-txn", null), shard, - datastoreContext, shardStats, "txn", DataStoreVersions.CURRENT_VERSION); + final Props props = ShardTransaction.props(RO, store.newReadOnlyTransaction(nextTransactionId()), shard, + datastoreContext, shardStats); final TestActorRef subject = TestActorRef.create(getSystem(), props, "testNegativeReadWithReadOnlyTransactionClosed"); Future future = akka.pattern.Patterns.ask(subject, - new ReadData(YangInstanceIdentifier.EMPTY), 3000); + new ReadData(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000); Await.result(future, Duration.create(3, TimeUnit.SECONDS)); subject.underlyingActor().getDOMStoreTransaction().abort(); - future = akka.pattern.Patterns.ask(subject, new ReadData(YangInstanceIdentifier.EMPTY), 3000); + future = akka.pattern.Patterns.ask(subject, new ReadData(YangInstanceIdentifier.EMPTY, + DataStoreVersions.CURRENT_VERSION), 3000); Await.result(future, Duration.create(3, TimeUnit.SECONDS)); } @@ -80,19 +84,20 @@ public class ShardTransactionFailureTest extends AbstractActorTest { public void testNegativeReadWithReadWriteTransactionClosed() throws Throwable { final ActorRef shard = createShard(); - final Props props = ShardTransaction.props(RW, store.newReadWriteTransaction("test-txn", null), shard, - datastoreContext, shardStats, "txn", DataStoreVersions.CURRENT_VERSION); + final Props props = ShardTransaction.props(RW, store.newReadWriteTransaction(nextTransactionId()), shard, + datastoreContext, shardStats); final TestActorRef subject = TestActorRef.create(getSystem(), props, "testNegativeReadWithReadWriteTransactionClosed"); Future future = akka.pattern.Patterns.ask(subject, - new ReadData(YangInstanceIdentifier.EMPTY), 3000); + new ReadData(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000); Await.result(future, Duration.create(3, TimeUnit.SECONDS)); subject.underlyingActor().getDOMStoreTransaction().abort(); - future = akka.pattern.Patterns.ask(subject, new ReadData(YangInstanceIdentifier.EMPTY), 3000); + future = akka.pattern.Patterns.ask(subject, new ReadData(YangInstanceIdentifier.EMPTY, + DataStoreVersions.CURRENT_VERSION), 3000); Await.result(future, Duration.create(3, TimeUnit.SECONDS)); } @@ -100,19 +105,20 @@ public class ShardTransactionFailureTest extends AbstractActorTest { public void testNegativeExistsWithReadWriteTransactionClosed() throws Throwable { final ActorRef shard = createShard(); - final Props props = ShardTransaction.props(RW, store.newReadWriteTransaction("test-txn", null), shard, - datastoreContext, shardStats, "txn", DataStoreVersions.CURRENT_VERSION); + final Props props = ShardTransaction.props(RW, store.newReadWriteTransaction(nextTransactionId()), shard, + datastoreContext, shardStats); final TestActorRef subject = TestActorRef.create(getSystem(), props, "testNegativeExistsWithReadWriteTransactionClosed"); Future future = akka.pattern.Patterns.ask(subject, - new DataExists(YangInstanceIdentifier.EMPTY), 3000); + new DataExists(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000); Await.result(future, Duration.create(3, TimeUnit.SECONDS)); subject.underlyingActor().getDOMStoreTransaction().abort(); - future = akka.pattern.Patterns.ask(subject, new DataExists(YangInstanceIdentifier.EMPTY), 3000); + future = akka.pattern.Patterns.ask(subject, + new DataExists(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000); Await.result(future, Duration.create(3, TimeUnit.SECONDS)); } }