예제 #1
0
        public void ShouldDownAllMembersWhenNotEnoughNodes()
        {
            string refereeAddress = "akka.tcp://system@localhost:33333";

            var referee = TestUtils.CreateMember(MemberStatus.Up, Address.Parse(refereeAddress));

            var members =
                TestUtils.CreateMembers(MemberStatus.Up)
                .Take(4)
                .Concat(new List <Member> {
                referee
            })
                .ToImmutableSortedSet();

            var unreachable =
                members.Where(m => m != referee)
                .Take(2)
                .ToImmutableHashSet();

            var state    = new CurrentClusterState().Copy(members, unreachable);
            var strategy = new KeepRefereeDowningStrategy(refereeAddress, downAllIfLessThanNodes: 4);

            var victims = strategy.GetVictims(state);

            victims.ToImmutableHashSet().SetEquals(members)
            .Should().BeTrue("We have 3 available members, which is less than downAllIfLessThanNodes 4, so down all members");
        }
예제 #2
0
        public void ShouldDownMembersInPartitionsWithoutReferee()
        {
            string refereeAddress = "akka.tcp://system@localhost:33333";

            var referee = TestUtils.CreateMember(MemberStatus.Up, Address.Parse(refereeAddress));

            var members =
                TestUtils.CreateMembers(MemberStatus.Up)
                .Take(4)
                .Concat(new List <Member> {
                referee
            })
                .ToImmutableSortedSet();

            var unreachable =
                members.Where(m => m != referee)
                .Take(2)
                .Concat(new List <Member> {
                referee
            })
                .ToImmutableHashSet();

            var state    = new CurrentClusterState().Copy(members, unreachable);
            var strategy = new KeepRefereeDowningStrategy(refereeAddress, downAllIfLessThanNodes: 0);

            var victims = strategy.GetVictims(state);

            victims.ToImmutableHashSet().SetEquals(members)
            .Should().BeTrue("When we don't have the referee, we down all members");
        }