From 16e5d445e88b9904d152248654409fd50bb88a4b Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Tue, 19 Aug 2014 18:49:06 -0700 Subject: [PATCH] Patch to eliminate sleeps in RemoteRpc tests Instead of using sleeps to wait for message processing to complete the tests now installs a probe on the subject(actor). Subject(actor) sends message to the probe when it processes message. The test monitors the probe for specific messages and knows when the message has been processed by the subject(actor). Patch#2: Fixed probe creation and updated assertions Change-Id: I10652b59e4138adbe6c6821d4411b06e1b3f1598 Signed-off-by: Moiz Raja Signed-off-by: Abhishek Kumar --- .../remote/rpc/registry/RpcRegistry.java | 2 + .../rpc/registry/gossip/BucketStore.java | 41 +- .../controller/utils/ConditionalProbe.java | 32 ++ .../remote/rpc/registry/RpcRegistryTest.java | 418 +++++++++--------- .../src/test/resources/application.conf | 5 +- .../src/test/resources/logback.xml | 13 + 6 files changed, 287 insertions(+), 224 deletions(-) create mode 100644 opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/utils/ConditionalProbe.java create mode 100644 opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/logback.xml diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java index e2ebcb2b25..76f5930457 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistry.java @@ -60,6 +60,8 @@ public class RpcRegistry extends UntypedActor { public RpcRegistry() { bucketStore = getContext().actorOf(Props.create(BucketStore.class), "store"); + + log.info("Bucket store path = {}", bucketStore.path().toString()); } public RpcRegistry(ActorRef bucketStore) { diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java index 2f634ce1fa..23cbaca32f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStore.java @@ -15,6 +15,7 @@ import akka.actor.UntypedActor; import akka.cluster.Cluster; import akka.event.Logging; import akka.event.LoggingAdapter; +import org.opendaylight.controller.utils.ConditionalProbe; import java.util.HashMap; import java.util.Map; @@ -71,6 +72,8 @@ public class BucketStore extends UntypedActor { */ private ActorRef gossiper; + private ConditionalProbe probe; + public BucketStore(){ gossiper = getContext().actorOf(Props.create(Gossiper.class), "gossiper"); } @@ -88,27 +91,32 @@ public class BucketStore extends UntypedActor { @Override public void onReceive(Object message) throws Exception { - log.debug("Received message: node[{}], message[{}]", selfAddress, message); + log.debug("Received message: node[{}], message[{}]", selfAddress, + message); - if (message instanceof UpdateBucket) - receiveUpdateBucket(((UpdateBucket) message).getBucket()); + if (probe != null) { - else if (message instanceof GetAllBuckets) - receiveGetAllBucket(); + probe.tell(message, getSelf()); + } - else if (message instanceof GetLocalBucket) + if (message instanceof ConditionalProbe) { + log.info("Received probe {} {}", getSelf(), message); + probe = (ConditionalProbe) message; + } else if (message instanceof UpdateBucket) { + receiveUpdateBucket(((UpdateBucket) message).getBucket()); + } else if (message instanceof GetAllBuckets) { + receiveGetAllBucket(); + } else if (message instanceof GetLocalBucket) { receiveGetLocalBucket(); - - else if (message instanceof GetBucketsByMembers) - receiveGetBucketsByMembers(((GetBucketsByMembers) message).getMembers()); - - else if (message instanceof GetBucketVersions) + } else if (message instanceof GetBucketsByMembers) { + receiveGetBucketsByMembers( + ((GetBucketsByMembers) message).getMembers()); + } else if (message instanceof GetBucketVersions) { receiveGetBucketVersions(); - - else if (message instanceof UpdateRemoteBuckets) - receiveUpdateRemoteBuckets(((UpdateRemoteBuckets) message).getBuckets()); - - else { + } else if (message instanceof UpdateRemoteBuckets) { + receiveUpdateRemoteBuckets( + ((UpdateRemoteBuckets) message).getBuckets()); + } else { log.debug("Unhandled message [{}]", message); unhandled(message); } @@ -270,4 +278,5 @@ public class BucketStore extends UntypedActor { Address getSelfAddress() { return selfAddress; } + } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/utils/ConditionalProbe.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/utils/ConditionalProbe.java new file mode 100644 index 0000000000..13cec54175 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/utils/ConditionalProbe.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.utils; + +import akka.actor.ActorRef; +import com.google.common.base.Predicate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConditionalProbe { + private final ActorRef actorRef; + private final Predicate predicate; + Logger log = LoggerFactory.getLogger(ConditionalProbe.class); + + public ConditionalProbe(ActorRef actorRef, Predicate predicate) { + this.actorRef = actorRef; + this.predicate = predicate; + } + + public void tell(Object message, ActorRef sender){ + if(predicate.apply(message)) { + log.info("sending message to probe {}", message); + actorRef.tell(message, sender); + } + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java index da3942a828..e6793741a3 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java @@ -1,14 +1,16 @@ package org.opendaylight.controller.remote.rpc.registry; + import akka.actor.ActorPath; import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.ChildActorPath; import akka.actor.Props; -import akka.japi.Pair; import akka.testkit.JavaTestKit; +import com.google.common.base.Predicate; import com.typesafe.config.ConfigFactory; + import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -16,267 +18,269 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.remote.rpc.RouteIdentifierImpl; +import org.opendaylight.controller.remote.rpc.registry.gossip.Messages; import org.opendaylight.controller.sal.connector.api.RpcRouter; +import org.opendaylight.controller.utils.ConditionalProbe; import org.opendaylight.yangtools.yang.common.QName; import scala.concurrent.Await; import scala.concurrent.Future; import scala.concurrent.duration.FiniteDuration; +import javax.annotation.Nullable; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; +import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter; import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes; import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes; -import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.FindRouters; -import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.FindRoutersReply; -import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter; public class RpcRegistryTest { - private static ActorSystem node1; - private static ActorSystem node2; - private static ActorSystem node3; - - private ActorRef registry1; - private ActorRef registry2; - private ActorRef registry3; - - @BeforeClass - public static void setup() throws InterruptedException { - Thread.sleep(1000); //give some time for previous test to close netty ports - node1 = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("memberA")); - node2 = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("memberB")); - node3 = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("memberC")); - } - - @AfterClass - public static void teardown(){ - JavaTestKit.shutdownActorSystem(node1); - JavaTestKit.shutdownActorSystem(node2); - JavaTestKit.shutdownActorSystem(node3); - if (node1 != null) - node1.shutdown(); - if (node2 != null) - node2.shutdown(); - if (node3 != null) - node3.shutdown(); - - } - - @Before - public void createRpcRegistry() throws InterruptedException { - registry1 = node1.actorOf(Props.create(RpcRegistry.class)); - registry2 = node2.actorOf(Props.create(RpcRegistry.class)); - registry3 = node3.actorOf(Props.create(RpcRegistry.class)); - } - - @After - public void stopRpcRegistry() throws InterruptedException { - if (registry1 != null) - node1.stop(registry1); - if (registry2 != null) - node2.stop(registry2); - if (registry3 != null) - node3.stop(registry3); - } + private static ActorSystem node1; + private static ActorSystem node2; + private static ActorSystem node3; + + private ActorRef registry1; + private ActorRef registry2; + private ActorRef registry3; + + @BeforeClass + public static void setup() throws InterruptedException { + node1 = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("memberA")); + node2 = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("memberB")); + node3 = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("memberC")); + } + + @AfterClass + public static void teardown() { + JavaTestKit.shutdownActorSystem(node1); + JavaTestKit.shutdownActorSystem(node2); + JavaTestKit.shutdownActorSystem(node3); + if (node1 != null) + node1.shutdown(); + if (node2 != null) + node2.shutdown(); + if (node3 != null) + node3.shutdown(); + + } + + @Before + public void createRpcRegistry() throws InterruptedException { + registry1 = node1.actorOf(Props.create(RpcRegistry.class)); + registry2 = node2.actorOf(Props.create(RpcRegistry.class)); + registry3 = node3.actorOf(Props.create(RpcRegistry.class)); + } + + @After + public void stopRpcRegistry() throws InterruptedException { + if (registry1 != null) + node1.stop(registry1); + if (registry2 != null) + node2.stop(registry2); + if (registry3 != null) + node3.stop(registry3); + } + + /** + * One node cluster. + * 1. Register rpc, ensure router can be found + * 2. Then remove rpc, ensure its deleted + * + * @throws URISyntaxException + * @throws InterruptedException + */ + @Test + public void testAddRemoveRpcOnSameNode() throws URISyntaxException, InterruptedException { + validateSystemStartup(); + + final JavaTestKit mockBroker = new JavaTestKit(node1); + + final ActorPath bucketStorePath = new ChildActorPath(registry1.path(), "store"); + + //install probe + final JavaTestKit probe1 = createProbeForMessage( + node1, bucketStorePath, Messages.BucketStoreMessages.UpdateBucket.class); + + //Add rpc on node 1 + registry1.tell(new SetLocalRouter(mockBroker.getRef()), mockBroker.getRef()); + registry1.tell(getAddRouteMessage(), mockBroker.getRef()); + + //Bucket store should get an update bucket message. Updated bucket contains added rpc. + probe1.expectMsgClass( + FiniteDuration.apply(10, TimeUnit.SECONDS), + Messages.BucketStoreMessages.UpdateBucket.class); + + //Now remove rpc + registry1.tell(getRemoveRouteMessage(), mockBroker.getRef()); + + //Bucket store should get an update bucket message. Rpc is removed in the updated bucket + probe1.expectMsgClass( + FiniteDuration.apply(10, TimeUnit.SECONDS), + Messages.BucketStoreMessages.UpdateBucket.class); + + + } + + + /** + * Three node cluster. + * 1. Register rpc on 1 node, ensure 2nd node gets updated + * 2. Remove rpc on 1 node, ensure 2nd node gets updated + * + * @throws URISyntaxException + * @throws InterruptedException + */ + @Test + public void testRpcAddRemoveInCluster() throws URISyntaxException, InterruptedException { - /** - * One node cluster. - * 1. Register rpc, ensure router can be found - * 2. Then remove rpc, ensure its deleted - * - * @throws URISyntaxException - * @throws InterruptedException - */ - @Test - public void testAddRemoveRpcOnSameNode() throws URISyntaxException, InterruptedException { - - final JavaTestKit mockBroker = new JavaTestKit(node1); - - //Add rpc on node 1 - registry1.tell(new SetLocalRouter(mockBroker.getRef()), mockBroker.getRef()); - registry1.tell(getAddRouteMessage(), mockBroker.getRef()); - - Thread.sleep(1000);// - - //find the route on node 1's registry - registry1.tell(new FindRouters(createRouteId()), mockBroker.getRef()); - FindRoutersReply message = mockBroker.expectMsgClass(JavaTestKit.duration("10 second"), FindRoutersReply.class); - List> pairs = message.getRouterWithUpdateTime(); - - validateRouterReceived(pairs, mockBroker.getRef()); - - //Now remove rpc - registry1.tell(getRemoveRouteMessage(), mockBroker.getRef()); - Thread.sleep(1000); - //find the route on node 1's registry - registry1.tell(new FindRouters(createRouteId()), mockBroker.getRef()); - message = mockBroker.expectMsgClass(JavaTestKit.duration("10 second"), FindRoutersReply.class); - pairs = message.getRouterWithUpdateTime(); - - Assert.assertTrue(pairs.isEmpty()); - } + validateSystemStartup(); + + final JavaTestKit mockBroker1 = new JavaTestKit(node1); + + //install probe on node2's bucket store + final ActorPath bucketStorePath = new ChildActorPath(registry2.path(), "store"); + final JavaTestKit probe2 = createProbeForMessage( + node2, bucketStorePath, Messages.BucketStoreMessages.UpdateRemoteBuckets.class); - /** - * Three node cluster. - * 1. Register rpc on 1 node, ensure its router can be found on other 2. - * 2. Remove rpc on 1 node, ensure its removed on other 2. - * - * @throws URISyntaxException - * @throws InterruptedException - */ - @Test - public void testRpcAddRemoveInCluster() throws URISyntaxException, InterruptedException { - validateSystemStartup(); + //Add rpc on node 1 + registry1.tell(new SetLocalRouter(mockBroker1.getRef()), mockBroker1.getRef()); + registry1.tell(getAddRouteMessage(), mockBroker1.getRef()); - final JavaTestKit mockBroker1 = new JavaTestKit(node1); - final JavaTestKit mockBroker2 = new JavaTestKit(node2); - final JavaTestKit mockBroker3 = new JavaTestKit(node3); + //Bucket store on node2 should get a message to update its local copy of remote buckets + probe2.expectMsgClass( + FiniteDuration.apply(10, TimeUnit.SECONDS), + Messages.BucketStoreMessages.UpdateRemoteBuckets.class); - //Add rpc on node 1 - registry1.tell(new SetLocalRouter(mockBroker1.getRef()), mockBroker1.getRef()); - registry1.tell(getAddRouteMessage(), mockBroker1.getRef()); + //Now remove + registry1.tell(getRemoveRouteMessage(), mockBroker1.getRef()); - Thread.sleep(1000);// give some time for bucket store data sync + //Bucket store on node2 should get a message to update its local copy of remote buckets + probe2.expectMsgClass( + FiniteDuration.apply(10, TimeUnit.SECONDS), + Messages.BucketStoreMessages.UpdateRemoteBuckets.class); - //find the route in node 2's registry - List> pairs = findRouters(registry2, mockBroker2); - validateRouterReceived(pairs, mockBroker1.getRef()); + } - //find the route in node 3's registry - pairs = findRouters(registry3, mockBroker3); - validateRouterReceived(pairs, mockBroker1.getRef()); + /** + * Three node cluster. + * Register rpc on 2 nodes. Ensure 3rd gets updated. + * + * @throws Exception + */ + @Test + public void testRpcAddedOnMultiNodes() throws Exception { - //Now remove - registry1.tell(getRemoveRouteMessage(), mockBroker1.getRef()); - Thread.sleep(1000);// give some time for bucket store data sync + validateSystemStartup(); - pairs = findRouters(registry2, mockBroker2); - Assert.assertTrue(pairs.isEmpty()); + final JavaTestKit mockBroker1 = new JavaTestKit(node1); + final JavaTestKit mockBroker2 = new JavaTestKit(node2); + final JavaTestKit mockBroker3 = new JavaTestKit(node3); - pairs = findRouters(registry3, mockBroker3); - Assert.assertTrue(pairs.isEmpty()); - } + registry3.tell(new SetLocalRouter(mockBroker3.getRef()), mockBroker3.getRef()); - /** - * Three node cluster. - * Register rpc on 2 nodes. Ensure 2 routers are found on 3rd. - * - * @throws Exception - */ - @Test - public void testAnRpcAddedOnMultiNodesShouldReturnMultiRouter() throws Exception { + //install probe on node 3 + final ActorPath bucketStorePath = new ChildActorPath(registry3.path(), "store"); + final JavaTestKit probe3 = createProbeForMessage( + node3, bucketStorePath, Messages.BucketStoreMessages.UpdateRemoteBuckets.class); - validateSystemStartup(); - final JavaTestKit mockBroker1 = new JavaTestKit(node1); - final JavaTestKit mockBroker2 = new JavaTestKit(node2); - final JavaTestKit mockBroker3 = new JavaTestKit(node3); + //Add rpc on node 1 + registry1.tell(new SetLocalRouter(mockBroker1.getRef()), mockBroker1.getRef()); + registry1.tell(getAddRouteMessage(), mockBroker1.getRef()); - //Thread.sleep(5000);//let system come up + probe3.expectMsgClass( + FiniteDuration.apply(10, TimeUnit.SECONDS), + Messages.BucketStoreMessages.UpdateRemoteBuckets.class); - //Add rpc on node 1 - registry1.tell(new SetLocalRouter(mockBroker1.getRef()), mockBroker1.getRef()); - registry1.tell(getAddRouteMessage(), mockBroker1.getRef()); - //Add same rpc on node 2 - registry2.tell(new SetLocalRouter(mockBroker2.getRef()), mockBroker2.getRef()); - registry2.tell(getAddRouteMessage(), mockBroker2.getRef()); + //Add same rpc on node 2 + registry2.tell(new SetLocalRouter(mockBroker2.getRef()), mockBroker2.getRef()); + registry2.tell(getAddRouteMessage(), mockBroker2.getRef()); - registry3.tell(new SetLocalRouter(mockBroker3.getRef()), mockBroker3.getRef()); - Thread.sleep(1000);// give some time for bucket store data sync + probe3.expectMsgClass( + FiniteDuration.apply(10, TimeUnit.SECONDS), + Messages.BucketStoreMessages.UpdateRemoteBuckets.class); + } - //find the route in node 3's registry - registry3.tell(new FindRouters(createRouteId()), mockBroker3.getRef()); - FindRoutersReply message = mockBroker3.expectMsgClass(JavaTestKit.duration("10 second"), FindRoutersReply.class); - List> pairs = message.getRouterWithUpdateTime(); + private JavaTestKit createProbeForMessage(ActorSystem node, ActorPath subjectPath, final Class clazz) { + final JavaTestKit probe = new JavaTestKit(node); - validateMultiRouterReceived(pairs, mockBroker1.getRef(), mockBroker2.getRef()); + ConditionalProbe conditionalProbe = + new ConditionalProbe(probe.getRef(), new Predicate() { + @Override + public boolean apply(@Nullable Object input) { + return clazz.equals(input.getClass()); + } + }); - } + ActorSelection subject = node.actorSelection(subjectPath); + subject.tell(conditionalProbe, ActorRef.noSender()); - private List> findRouters(ActorRef registry, JavaTestKit receivingActor) throws URISyntaxException { - registry.tell(new FindRouters(createRouteId()), receivingActor.getRef()); - FindRoutersReply message = receivingActor.expectMsgClass(JavaTestKit.duration("10 second"), FindRoutersReply.class); - return message.getRouterWithUpdateTime(); - } + return probe; - private void validateMultiRouterReceived(List> actual, ActorRef... expected) { - Assert.assertTrue(actual != null); - Assert.assertTrue(actual.size() == expected.length); - } + } - private void validateRouterReceived(List> actual, ActorRef expected){ - Assert.assertTrue(actual != null); - Assert.assertTrue(actual.size() == 1); + private void validateSystemStartup() throws InterruptedException { - for (Pair pair : actual){ - Assert.assertTrue(expected.path().uid() == pair.first().path().uid()); - } - } + ActorPath gossiper1Path = new ChildActorPath(new ChildActorPath(registry1.path(), "store"), "gossiper"); + ActorPath gossiper2Path = new ChildActorPath(new ChildActorPath(registry2.path(), "store"), "gossiper"); + ActorPath gossiper3Path = new ChildActorPath(new ChildActorPath(registry3.path(), "store"), "gossiper"); - private void validateSystemStartup() throws InterruptedException { + ActorSelection gossiper1 = node1.actorSelection(gossiper1Path); + ActorSelection gossiper2 = node2.actorSelection(gossiper2Path); + ActorSelection gossiper3 = node3.actorSelection(gossiper3Path); - Thread.sleep(5000); - ActorPath gossiper1Path = new ChildActorPath(new ChildActorPath(registry1.path(), "store"), "gossiper"); - ActorPath gossiper2Path = new ChildActorPath(new ChildActorPath(registry2.path(), "store"), "gossiper"); - ActorPath gossiper3Path = new ChildActorPath(new ChildActorPath(registry3.path(), "store"), "gossiper"); - ActorSelection gossiper1 = node1.actorSelection(gossiper1Path); - ActorSelection gossiper2 = node2.actorSelection(gossiper2Path); - ActorSelection gossiper3 = node3.actorSelection(gossiper3Path); + if (!resolveReference(gossiper1, gossiper2, gossiper3)) + Assert.fail("Could not find gossipers"); + } + private Boolean resolveReference(ActorSelection... gossipers) { - if (!resolveReference(gossiper1, gossiper2, gossiper3)) - Assert.fail("Could not find gossipers"); - } + Boolean resolved = true; + for (int i = 0; i < 5; i++) { - private Boolean resolveReference(ActorSelection... gossipers) throws InterruptedException { + resolved = true; + System.out.println(System.currentTimeMillis() + " Resolving gossipers; trial #" + i); - Boolean resolved = true; + for (ActorSelection gossiper : gossipers) { + ActorRef ref = null; - for (int i=0; i< 5; i++) { - Thread.sleep(1000); - for (ActorSelection gossiper : gossipers) { - Future future = gossiper.resolveOne(new FiniteDuration(5000, TimeUnit.MILLISECONDS)); + try { + Future future = gossiper.resolveOne(new FiniteDuration(15000, TimeUnit.MILLISECONDS)); + ref = Await.result(future, new FiniteDuration(10000, TimeUnit.MILLISECONDS)); + } catch (Exception e) { + System.out.println("Could not find gossiper in attempt#" + i + ". Got exception " + e.getMessage()); + } - ActorRef ref = null; - try { - ref = Await.result(future, new FiniteDuration(10000, TimeUnit.MILLISECONDS)); - } catch (Exception e) { - e.printStackTrace(); - } + if (ref == null) + resolved = false; + } - if (ref == null) - resolved = false; - } + if (resolved) break; - if (resolved) break; - } - return resolved; } + return resolved; + } - private AddOrUpdateRoutes getAddRouteMessage() throws URISyntaxException { - return new AddOrUpdateRoutes(createRouteIds()); - } + private AddOrUpdateRoutes getAddRouteMessage() throws URISyntaxException { + return new AddOrUpdateRoutes(createRouteIds()); + } - private RemoveRoutes getRemoveRouteMessage() throws URISyntaxException { - return new RemoveRoutes(createRouteIds()); - } + private RemoveRoutes getRemoveRouteMessage() throws URISyntaxException { + return new RemoveRoutes(createRouteIds()); + } - private List> createRouteIds() throws URISyntaxException { - QName type = new QName(new URI("/mockrpc"), "mockrpc"); - List> routeIds = new ArrayList<>(); - routeIds.add(new RouteIdentifierImpl(null, type, null)); - return routeIds; - } + private List> createRouteIds() throws URISyntaxException { + QName type = new QName(new URI("/mockrpc"), "mockrpc"); + List> routeIds = new ArrayList<>(); + routeIds.add(new RouteIdentifierImpl(null, type, null)); + return routeIds; + } - private RpcRouter.RouteIdentifier createRouteId() throws URISyntaxException { - QName type = new QName(new URI("/mockrpc"), "mockrpc"); - return new RouteIdentifierImpl(null, type, null); - } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/application.conf b/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/application.conf index 61fab7e0fe..b578d6f04f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/application.conf +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/application.conf @@ -1,6 +1,6 @@ odl-cluster{ akka { - loglevel = "INFO" + loglevel = "DEBUG" #log-config-on-start = on actor { @@ -45,6 +45,9 @@ memberA{ loggers = ["akka.event.slf4j.Slf4jLogger"] actor { provider = "akka.cluster.ClusterActorRefProvider" + debug { + #lifecycle = on + } } remote { log-received-messages = off diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/logback.xml b/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/logback.xml new file mode 100644 index 0000000000..5246f01d05 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + -- 2.36.6