A_remote_random_pool_must_be_locally_instantiated_on_a_remote_node_and_be_able_to_communicate_through_its_remote_actor_ref()
{
RunOn(() => { EnterBarrier("start", "broadcast-end", "end", "done"); },
_config.First, _config.Second, _config.Third);
var runOnFourth = new Action(() =>
{
EnterBarrier("start");
var actor = Sys.ActorOf(new RandomPool(nrOfInstances: 0)
.Props(Props.Create<SomeActor>()), "service-hello");
Assert.IsType<RoutedActorRef>(actor);
var connectionCount = 3;
var iterationCount = 100;
for (var i = 0; i < iterationCount; i++)
for (var k = 0; k < connectionCount; k++)
actor.Tell("hit");
var replies = ReceiveWhile(TimeSpan.FromSeconds(5), x =>
{
if (x is IActorRef) return x.AsInstanceOf<IActorRef>().Path.Address;
return null;
}, connectionCount * iterationCount)
.Aggregate(ImmutableDictionary<Address, int>.Empty
.Add(Node(_config.First).Address, 0)
.Add(Node(_config.Second).Address, 0)
.Add(Node(_config.Third).Address, 0),
(map, address) =>
{
var previous = map[address];
return map.Remove(address).Add(address, previous + 1);
});
EnterBarrier("broadcast-end");
actor.Tell(new Broadcast(PoisonPill.Instance));
EnterBarrier("end");
// since it's random we can't be too strict in the assert
replies.Values.Count(x => x > 0).ShouldBeGreaterThan(connectionCount - 2);
Assert.False(replies.ContainsKey(Node(_config.Fourth).Address));
Sys.Stop(actor);
EnterBarrier("done");
});
RunOn(runOnFourth, _config.Fourth);
}
}