public void ClusterClient_should_reestablish_connection_to_receptionist_after_partition()
{
ClusterClient_should_reestablish_connection_to_another_receptionist_when_server_is_shutdown();
Within(TimeSpan.FromSeconds(30), () =>
{
RunOn(() =>
{
var c = Sys.ActorOf(Client.ClusterClient.Props(ClusterClientSettings.Create(Sys).WithInitialContacts(InitialContacts)), "client3");
c.Tell(new Client.ClusterClient.Send("/user/service2", "bonjour2", localAffinity: true));
ExpectMsg("bonjour2-ack");
var lastSenderAddress = LastSender.Path.Address;
var receptionistRoleName = RoleName(lastSenderAddress);
if (receptionistRoleName == null) throw new Exception("Unexpected missing role name: " + lastSenderAddress);
// shutdown all but the one that the client is connected to
foreach (var roleName in _remainingServerRoleNames.ToArray())
if (!roleName.Equals(receptionistRoleName)) TestConductor.Exit(roleName, 0).Wait();
_remainingServerRoleNames = new HashSet<RoleName>(new[] { receptionistRoleName });
// network partition between client and server
TestConductor.Blackhole(_client, receptionistRoleName, ThrottleTransportAdapter.Direction.Both).Wait();
c.Tell(new Client.ClusterClient.Send("/user/service2", "ping", localAffinity: true));
// if we would use remote watch the failure detector would trigger and
// connection quarantined
ExpectNoMsg(TimeSpan.FromSeconds(5));
TestConductor.PassThrough(_client, receptionistRoleName, ThrottleTransportAdapter.Direction.Both).Wait();
var expectedAddress = Node(receptionistRoleName).Address;
AwaitAssert(() =>
{
c.Tell(new Client.ClusterClient.Send("/user/service2", "bonjour3", localAffinity: true));
ExpectMsg("bonjour3-ack", TimeSpan.FromSeconds(1));
var lastSenderAddress2 = LastSender.Path.Address;
Assert.Equal(expectedAddress, lastSenderAddress2);
});
Sys.Stop(c);
}, _client);
EnterBarrier("after-5");
});
}
}