Fix ReplicationAndSnapshotsIntegrationTest failure 32/19032/1
authorTom Pantelis <tpanteli@brocade.com>
Thu, 23 Apr 2015 13:25:11 +0000 (09:25 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 23 Apr 2015 13:25:11 +0000 (09:25 -0400)
Saw this fail sproradically a few times on jenkins with
InvalidActorNameException trying to kill and re-create the actor with
the same name. We wait for the actor to terminate but it seems it may
not be removed from akka at that point. So I added a retry loop for
creating the actor.

Change-Id: Ia2d7388b00df329d62a4683a18f49067cfdc17a0
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java

index 977cf0ef5eb60fc905ef7ce35177b46d23ed265b..579dea26387059f30d7bbc0f0064d91f195006ad 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 import akka.actor.ActorRef;
 
 import static org.junit.Assert.assertEquals;
 import akka.actor.ActorRef;
+import akka.actor.InvalidActorNameException;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.Terminated;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.Terminated;
@@ -19,6 +20,7 @@ import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -186,9 +188,20 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         TestActorRef<MessageCollectorActor> collectorActor = factory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                         factory.generateActorId(id + "-collector"));
         TestActorRef<MessageCollectorActor> collectorActor = factory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                         factory.generateActorId(id + "-collector"));
-        return factory.createTestActor(TestRaftActor.props(id,
-                peerAddresses != null ? peerAddresses : Collections.<String, String>emptyMap(),
-                        configParams, collectorActor), id);
+
+        InvalidActorNameException lastEx = null;
+        for(int i = 0; i < 10; i++) {
+            try {
+                return factory.createTestActor(TestRaftActor.props(id,
+                        peerAddresses != null ? peerAddresses : Collections.<String, String>emptyMap(),
+                                configParams, collectorActor), id);
+            } catch (InvalidActorNameException e) {
+                lastEx = e;
+                Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+            }
+        }
+
+        throw lastEx;
     }
 
     protected void killActor(TestActorRef<TestRaftActor> leaderActor) {
     }
 
     protected void killActor(TestActorRef<TestRaftActor> leaderActor) {