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%2FShardManagerTest.java;h=1feefd1c1fbcde3381d91332bd8d977048e7e074;hb=67d58d1ab50f3c3bbe19a96fb6f0d9d94211829f;hp=268ed3c27383f3254eafec08e74c8f287456456a;hpb=3b4aea96013998f11450f5b83e4527bebd27af6a;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java index 268ed3c273..1feefd1c1f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java @@ -42,11 +42,12 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), new DatastoreContext()); final TestActorRef subject = TestActorRef.create(system, props); - new Within(duration("1 seconds")) { + new Within(duration("10 seconds")) { + @Override protected void run() { subject.tell(new FindPrimary("inventory").toSerializable(), getRef()); @@ -66,16 +67,17 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), new DatastoreContext()); final TestActorRef subject = TestActorRef.create(system, props); - new Within(duration("1 seconds")) { + new Within(duration("10 seconds")) { + @Override protected void run() { subject.tell(new FindPrimary(Shard.DEFAULT_NAME).toSerializable(), getRef()); - expectMsgClass(PrimaryFound.SERIALIZABLE_CLASS); + expectMsgClass(duration("1 seconds"), PrimaryFound.SERIALIZABLE_CLASS); expectNoMsg(); } @@ -89,16 +91,18 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), new DatastoreContext()); final TestActorRef subject = TestActorRef.create(system, props); - new Within(duration("1 seconds")) { + new Within(duration("10 seconds")) { + @Override protected void run() { subject.tell(new FindLocalShard("inventory"), getRef()); - final String out = new ExpectMsg(duration("1 seconds"), "find local") { + final String out = new ExpectMsg(duration("10 seconds"), "find local") { + @Override protected String match(Object in) { if (in instanceof LocalShardNotFound) { return ((LocalShardNotFound) in).getShardName(); @@ -124,16 +128,18 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", mockClusterWrapper, - new MockConfiguration()); + new MockConfiguration(), new DatastoreContext()); final TestActorRef subject = TestActorRef.create(system, props); - new Within(duration("1 seconds")) { + new Within(duration("10 seconds")) { + @Override protected void run() { subject.tell(new FindLocalShard(Shard.DEFAULT_NAME), getRef()); - final ActorRef out = new ExpectMsg(duration("1 seconds"), "find local") { + final ActorRef out = new ExpectMsg(duration("10 seconds"), "find local") { + @Override protected ActorRef match(Object in) { if (in instanceof LocalShardFound) { return ((LocalShardFound) in).getPath(); @@ -158,20 +164,22 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), new DatastoreContext()); final TestActorRef subject = TestActorRef.create(system, props); // the run() method needs to finish within 3 seconds - new Within(duration("1 seconds")) { + new Within(duration("10 seconds")) { + @Override protected void run() { MockClusterWrapper.sendMemberUp(subject, "member-2", getRef().path().toString()); subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); - final String out = new ExpectMsg("primary found") { + final String out = new ExpectMsg(duration("1 seconds"), "primary found") { // do not put code outside this method, will run afterwards + @Override protected String match(Object in) { if (in.getClass().equals(PrimaryFound.SERIALIZABLE_CLASS)) { PrimaryFound f = PrimaryFound.fromSerializable(in); @@ -196,25 +204,26 @@ public class ShardManagerTest { new JavaTestKit(system) {{ final Props props = ShardManager .props("config", new MockClusterWrapper(), - new MockConfiguration()); + new MockConfiguration(), new DatastoreContext()); final TestActorRef subject = TestActorRef.create(system, props); // the run() method needs to finish within 3 seconds - new Within(duration("1 seconds")) { + new Within(duration("10 seconds")) { + @Override protected void run() { MockClusterWrapper.sendMemberUp(subject, "member-2", getRef().path().toString()); subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); - expectMsgClass(PrimaryFound.SERIALIZABLE_CLASS); + expectMsgClass(duration("1 seconds"), PrimaryFound.SERIALIZABLE_CLASS); MockClusterWrapper.sendMemberRemoved(subject, "member-2", getRef().path().toString()); subject.tell(new FindPrimary("astronauts").toSerializable(), getRef()); - expectMsgClass(PrimaryNotFound.SERIALIZABLE_CLASS); + expectMsgClass(duration("1 seconds"), PrimaryNotFound.SERIALIZABLE_CLASS); expectNoMsg(); }