public void Persistent_cluster_shards_should_be_migrated_to_new_regions_upon_region_failure()
{
Persistent_cluster_shards_should_restart_entities_which_stop_without_passivation();
Within(TimeSpan.FromSeconds(15), () =>
{
//Start only one region, and force an entity onto that region
RunOn(() =>
{
_autoMigrateRegion.Value.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
_autoMigrateRegion.Value.Tell(new Counter.Get(1));
ExpectMsg(1);
}, _third);
EnterBarrier("shard1-region3");
//Start another region and test it talks to node 3
RunOn(() =>
{
_autoMigrateRegion.Value.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
_autoMigrateRegion.Value.Tell(new Counter.Get(1));
ExpectMsg(2);
Assert.Equal(Node(_third) / "user" / "AutoMigrateRegionTestRegion" / "1" / "1", LastSender.Path);
// kill region 3
Sys.ActorSelection(LastSender.Path.Parent.Parent).Tell(PoisonPill.Instance);
}, _fourth);
EnterBarrier("region4-up");
// Wait for migration to happen
//Test the shard, thus counter was moved onto node 4 and started.
RunOn(() =>
{
var counter1 = Sys.ActorSelection(ActorPath.Parse("user") / "AutoMigrateRegionTestRegion" / "1" / "1");
var probe = CreateTestProbe();
AwaitAssert(() =>
{
counter1.Tell(new Identify(1), probe.Ref);
Assert.NotNull(probe.ExpectMsg<ActorIdentity>(TimeSpan.FromSeconds(1)).Subject);
}, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(500));
counter1.Tell(new Counter.Get(1));
ExpectMsg(2);
}, _fourth);
EnterBarrier("after-15");
});
}