public void ClusterSharding_should_rebalance_to_nodes_with_less_shards()
{
ClusterSharding_should_recover_coordinator_state_after_coordinator_crash();
Within(TimeSpan.FromSeconds(60), () =>
{
RunOn(() =>
{
for (int i = 1; i <= 10; i++)
{
var rebalancingRegion = _rebalancingRegion.Value;
rebalancingRegion.Tell(new Counter.EntityEnvelope(i, Counter.Increment.Instance));
rebalancingRegion.Tell(new Counter.Get(i));
ExpectMsg(1);
}
}, _fourth);
EnterBarrier("rebalancing-shards-allocated");
Join(_sixth, _third);
RunOn(() =>
{
AwaitAssert(() =>
{
var probe = CreateTestProbe();
Within(TimeSpan.FromSeconds(3), () =>
{
var count = 0;
for (int i = 1; i <= 10; i++)
{
var rebalancingRegion = _rebalancingRegion.Value;
rebalancingRegion.Tell(new Counter.Get(i), probe.Ref);
probe.ExpectMsg<int>();
if (probe.LastSender.Path.Equals(rebalancingRegion.Path / (i % 12).ToString() / i.ToString()))
count++;
}
Assert.True(count >= 2);
});
});
}, _sixth);
EnterBarrier("after-9");
});
}