protected void TestWaitMovingMembersToUp()
{
var onUpLatch = new TestLatch(1);
Cluster.RegisterOnMemberUp(() =>
{
onUpLatch.CountDown();
});
RunOn(() =>
{
Cluster.Join(GetAddress(Myself));
AwaitAssert(() =>
{
ClusterView.RefreshCurrentState();
ClusterView.Status.ShouldBe(MemberStatus.Joining);
});
}, First);
EnterBarrier("first-started");
onUpLatch.IsOpen.ShouldBeFalse();
RunOn(() =>
{
Cluster.Join(GetAddress(First));
}, Second);
RunOn(() =>
{
var expectedAddresses = new List<Address> { GetAddress(First), GetAddress(Second) };
AwaitAssert(() =>
{
ClusterView.RefreshCurrentState();
ClusterView.Members.Select(c => c.Address).Except(expectedAddresses).Count().ShouldBe(0);
});
ClusterView.Members.All(c => c.Status == MemberStatus.Joining).ShouldBeTrue();
// and it should not change
foreach (var _ in Enumerable.Range(1, 5))
{
Thread.Sleep(1000);
ClusterView.Members.Select(c => c.Address).Except(expectedAddresses).Count().ShouldBe(0);
ClusterView.Members.All(c => c.Status == MemberStatus.Joining).ShouldBeTrue();
}
}, First, Second);
EnterBarrier("second-joined");
RunOn(() =>
{
Cluster.Join(GetAddress(First));
}, Third);
AwaitClusterUp(First, Second, Third);
onUpLatch.Ready(TestKitSettings.DefaultTimeout);
EnterBarrier("after-1");
}
}