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%2FBasicIntegrationTest.java;h=50367e66ce3b759325d20228a63d0f7c2eeaab5d;hp=6599bd8eeb0d0b0b54d9058086d836fb82aa214a;hb=c33b2b55b2eae406df001619885a0610800cb951;hpb=5c7fe226016d6997f411601502589e86ad9d8f87 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java index 6599bd8eeb..50367e66ce 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/BasicIntegrationTest.java @@ -14,8 +14,9 @@ import akka.actor.ActorSelection; import akka.actor.Props; import akka.event.Logging; import akka.testkit.JavaTestKit; -import junit.framework.Assert; + import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionChain; @@ -30,6 +31,8 @@ import org.opendaylight.controller.cluster.datastore.messages.WriteData; import org.opendaylight.controller.cluster.datastore.messages.WriteDataReply; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + import scala.concurrent.Await; import scala.concurrent.Future; import scala.concurrent.duration.FiniteDuration; @@ -37,6 +40,8 @@ import scala.concurrent.duration.FiniteDuration; import java.util.Collections; import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; public class BasicIntegrationTest extends AbstractActorTest { @@ -52,22 +57,27 @@ public class BasicIntegrationTest extends AbstractActorTest { new JavaTestKit(getSystem()) {{ - final Props props = Shard.props("config", Collections.EMPTY_MAP); - final ActorRef shard = getSystem().actorOf(props); + final ShardIdentifier identifier = + ShardIdentifier.builder().memberName("member-1") + .shardName("inventory").type("config").build(); - new Within(duration("5 seconds")) { - protected void run() { + final SchemaContext schemaContext = TestModel.createTestContext(); + DatastoreContext datastoreContext = new DatastoreContext(); + final Props props = Shard.props(identifier, Collections.EMPTY_MAP, datastoreContext, TestModel.createTestContext()); + final ActorRef shard = getSystem().actorOf(props); - shard.tell( - new UpdateSchemaContext(TestModel.createTestContext()), - getRef()); + new Within(duration("10 seconds")) { + @Override + protected void run() { + shard.tell(new UpdateSchemaContext(schemaContext), getRef()); // Wait for a specific log message to show up final boolean result = new JavaTestKit.EventFilter(Logging.Info.class ) { + @Override protected Boolean run() { return true; } @@ -81,7 +91,8 @@ public class BasicIntegrationTest extends AbstractActorTest { shard.tell(new CreateTransactionChain().toSerializable(), getRef()); final ActorSelection transactionChain = - new ExpectMsg(duration("1 seconds"), "CreateTransactionChainReply") { + new ExpectMsg(duration("3 seconds"), "CreateTransactionChainReply") { + @Override protected ActorSelection match(Object in) { if (in.getClass().equals(CreateTransactionChainReply.SERIALIZABLE_CLASS)) { ActorPath transactionChainPath = @@ -95,7 +106,7 @@ public class BasicIntegrationTest extends AbstractActorTest { } }.get(); // this extracts the received message - Assert.assertNotNull(transactionChain); + assertNotNull(transactionChain); System.out.println("Successfully created transaction chain"); @@ -103,7 +114,8 @@ public class BasicIntegrationTest extends AbstractActorTest { transactionChain.tell(new CreateTransaction("txn-1", TransactionProxy.TransactionType.WRITE_ONLY.ordinal() ).toSerializable(), getRef()); final ActorSelection transaction = - new ExpectMsg(duration("1 seconds"), "CreateTransactionReply") { + new ExpectMsg(duration("3 seconds"), "CreateTransactionReply") { + @Override protected ActorSelection match(Object in) { if (CreateTransactionReply.SERIALIZABLE_CLASS.equals(in.getClass())) { CreateTransactionReply reply = CreateTransactionReply.fromSerializable(in); @@ -116,16 +128,17 @@ public class BasicIntegrationTest extends AbstractActorTest { } }.get(); // this extracts the received message - Assert.assertNotNull(transaction); + assertNotNull(transaction); System.out.println("Successfully created transaction"); // 3. Write some data transaction.tell(new WriteData(TestModel.TEST_PATH, - ImmutableNodes.containerNode(TestModel.TEST_QNAME), TestModel.createTestContext()).toSerializable(), + ImmutableNodes.containerNode(TestModel.TEST_QNAME), schemaContext).toSerializable(), getRef()); - Boolean writeDone = new ExpectMsg(duration("1 seconds"), "WriteDataReply") { + Boolean writeDone = new ExpectMsg(duration("3 seconds"), "WriteDataReply") { + @Override protected Boolean match(Object in) { if (in.getClass().equals(WriteDataReply.SERIALIZABLE_CLASS)) { return true; @@ -135,7 +148,7 @@ public class BasicIntegrationTest extends AbstractActorTest { } }.get(); // this extracts the received message - Assert.assertTrue(writeDone); + assertTrue(writeDone); System.out.println("Successfully wrote data"); @@ -144,7 +157,8 @@ public class BasicIntegrationTest extends AbstractActorTest { transaction.tell(new ReadyTransaction().toSerializable(), getRef()); final ActorSelection cohort = - new ExpectMsg(duration("1 seconds"), "ReadyTransactionReply") { + new ExpectMsg(duration("3 seconds"), "ReadyTransactionReply") { + @Override protected ActorSelection match(Object in) { if (in.getClass().equals(ReadyTransactionReply.SERIALIZABLE_CLASS)) { ActorPath cohortPath = @@ -158,7 +172,7 @@ public class BasicIntegrationTest extends AbstractActorTest { } }.get(); // this extracts the received message - Assert.assertNotNull(cohort); + assertNotNull(cohort); System.out.println("Successfully readied the transaction"); @@ -167,7 +181,8 @@ public class BasicIntegrationTest extends AbstractActorTest { cohort.tell(new PreCommitTransaction().toSerializable(), getRef()); Boolean preCommitDone = - new ExpectMsg(duration("1 seconds"), "PreCommitTransactionReply") { + new ExpectMsg(duration("3 seconds"), "PreCommitTransactionReply") { + @Override protected Boolean match(Object in) { if (in.getClass().equals(PreCommitTransactionReply.SERIALIZABLE_CLASS)) { return true; @@ -177,7 +192,7 @@ public class BasicIntegrationTest extends AbstractActorTest { } }.get(); // this extracts the received message - Assert.assertTrue(preCommitDone); + assertTrue(preCommitDone); System.out.println("Successfully pre-committed the transaction");