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>
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;
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;
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) {