Example #1
0
        public void ShouldDownRemoteOldestWhenOldestAndAlone()
        {
            var oldest = TestUtils.CreateMembers(MemberStatus.Up).First();

            var rest = TestUtils.CreateMembers(MemberStatus.Up)
                       .Take(4)
                       .ToImmutableSortedSet();

            var members     = rest.Add(oldest);
            var unreachable = ImmutableHashSet <Member> .Empty.Add(oldest);

            var state    = new CurrentClusterState().Copy(members, unreachable);
            var strategy = new KeepOldestDowningStrategy(downIfAlone: true);

            var victims = strategy.GetVictims(state);

            victims.ToImmutableHashSet().SetEquals(ImmutableHashSet <Member> .Empty.Add(oldest))
            .Should().BeTrue("When downIfAlone=true, we should down the oldest member if its clustered by itself");
        }
Example #2
0
        public void ShouldDownSelfWhenNotInOldestPartition()
        {
            var oldest = TestUtils.CreateMembers(MemberStatus.Up).First();

            var members = TestUtils.CreateMembers(MemberStatus.Up)
                          .Take(4)
                          .ToImmutableSortedSet()
                          .Add(oldest);

            var unreachable = ImmutableHashSet <Member> .Empty.Add(oldest);

            var state    = new CurrentClusterState().Copy(members, unreachable);
            var strategy = new KeepOldestDowningStrategy();

            var victims = strategy.GetVictims(state);

            victims.ToImmutableHashSet().SetEquals(members)
            .Should().BeTrue("When we don't have the oldest node, down ourselves");
        }
Example #3
0
        public void ShouldDownUnreachablesInOldestPartition()
        {
            var oldest = TestUtils.CreateMembers(MemberStatus.Up)
                         .Take(3)
                         .ToImmutableSortedSet();

            var newest = TestUtils.CreateMembers(MemberStatus.Up)
                         .Take(2)
                         .ToImmutableSortedSet();

            var members     = oldest.Union(newest);
            var unreachable = newest.ToImmutableHashSet();

            var state    = new CurrentClusterState().Copy(members, unreachable);
            var strategy = new KeepOldestDowningStrategy();

            var victims = strategy.GetVictims(state);

            victims.ToImmutableHashSet().SetEquals(unreachable)
            .Should().BeTrue("When we have the oldest node, the unreachable nodes should be downed");
        }
Example #4
0
        public void ShouldDownUnreachableWhenNoOldest()
        {
            var oldest = TestUtils.CreateMembers(MemberStatus.Up)
                         .Take(3)
                         .ToImmutableSortedSet();

            var members = TestUtils.CreateMembers(MemberStatus.Up)
                          .Take(5)
                          .ToImmutableSortedSet();

            var unreachable = members.Take(2).ToImmutableHashSet();

            var state = new CurrentClusterState().Copy(members, unreachable);

            //There will be no oldest when constrained to this role
            var strategy = new KeepOldestDowningStrategy(role: "SomeRole");

            var victims = strategy.GetVictims(state);

            victims.ToImmutableHashSet().SetEquals(unreachable)
            .Should().BeTrue("When there isn't an oldest node, the unreachable nodes should be downed");
        }