public void Must_receive_terminated_when_remote_actor_system_is_restarted()
{
RunOn(() =>
{
var secondAddress = Node(_specConfig.Second).Address;
EnterBarrier("actors-started");
var subject = Identify(_specConfig.Second, "subject");
Watch(subject);
subject.Tell("hello");
ExpectMsg("hello");
EnterBarrier("watch-established");
// simulate a hard shutdown, nothing sent from the shutdown node
TestConductor.Blackhole(_specConfig.Second, _specConfig.First, ThrottleTransportAdapter.Direction.Send)
.GetAwaiter()
.GetResult();
TestConductor.Shutdown(_specConfig.Second).GetAwaiter().GetResult();
ExpectTerminated(subject, TimeSpan.FromSeconds(20));
Within(TimeSpan.FromSeconds(10), () =>
{
// retry because the Subject actor might not be started yet
AwaitAssert(() =>
{
Sys.ActorSelection(new RootActorPath(secondAddress)/"user"/
"subject").Tell("shutdown");
ExpectMsg<string>(msg => { return "shutdown-ack" == msg; }, TimeSpan.FromSeconds(1));
});
});
}, _specConfig.First);
RunOn(() =>
{
var addr = Sys.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
Sys.ActorOf(Props.Create(() => new Subject()), "subject");
EnterBarrier("actors-started");
EnterBarrier("watch-established");
Sys.WhenTerminated.Wait(TimeSpan.FromSeconds(30));
var sb = new StringBuilder().AppendLine("akka.remote.helios.tcp {").AppendLine("hostname = " + addr.Host)
.AppendLine("port = " + addr.Port)
.AppendLine("}");
var freshSystem = ActorSystem.Create(Sys.Name,
ConfigurationFactory.ParseString(sb.ToString()).WithFallback(Sys.Settings.Config));
freshSystem.ActorOf(Props.Create(() => new Subject()), "subject");
freshSystem.WhenTerminated.Wait(TimeSpan.FromSeconds(30));
}, _specConfig.Second);
}