Exemplo n.º 1
0
        public void A_gossip_must_merge_seen_table_correctly()
        {
            var vclockNode = VectorClock.Node.Create("something");
            var g1         = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                             .Seen(a1.UniqueAddress)
                             .Seen(b1.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                     .Seen(a1.UniqueAddress)
                     .Seen(c1.UniqueAddress);
            var g3 = g1.Copy(version: g2.Version).Seen(d1.UniqueAddress);

            Action <Gossip> checkMerge = merged =>
            {
                var seen = merged.Overview.Seen;
                seen.Count.Should().Be(0);

                merged.SeenByNode(a1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(b1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(c1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(d1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(e1.UniqueAddress).Should().BeFalse();
            };

            checkMerge(g3.Merge(g2));
            checkMerge(g2.Merge(g3));
        }
Exemplo n.º 2
0
        public void AGossipMustMergeSeenTableCorrectly()
        {
            var vclockNode = VectorClock.Node.Create("something");
            var g1         =
                new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                .Seen(a1.UniqueAddress)
                .Seen(b1.UniqueAddress);
            var g2 =
                new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                .Seen(a1.UniqueAddress)
                .Seen(c1.UniqueAddress);
            var g3 = g1.Copy(version: g2.Version).Seen(d1.UniqueAddress);

            Action <Gossip> checkMerge = (m) =>
            {
                var seen = m.Overview.Seen;
                Assert.Equal(0, seen.Count());

                Assert.False(m.SeenByNode(a1.UniqueAddress));
                Assert.False(m.SeenByNode(b1.UniqueAddress));
                Assert.False(m.SeenByNode(c1.UniqueAddress));
                Assert.False(m.SeenByNode(d1.UniqueAddress));
                Assert.False(m.SeenByNode(e1.UniqueAddress));
            };

            checkMerge(g3.Merge(g2));
            checkMerge(g2.Merge(g3));
        }
Exemplo n.º 3
0
        public void AGossipMustMergeMembersByRemovingRemovedMembers()
        {
            // c3 removed
            var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1), new GossipOverview(r1));
            var r2 = r1.Unreachable(b1.UniqueAddress, c3.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c3), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);
            Assert.Equal(ImmutableHashSet.Create(a1, b1), merged1.Members);
            Assert.Equal(ImmutableHashSet.Create(a1.UniqueAddress), merged1.Overview.Reachability.AllUnreachable);


            var merged2 = g2.Merge(g1);
            Assert.Equal(merged2.Overview.Reachability.AllUnreachable, merged1.Overview.Reachability.AllUnreachable);
            Assert.Equal(merged1.Members, merged2.Members);
        }
Exemplo n.º 4
0
        public void AGossipMustMergeUnreachable()
        {
            var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress)
                .Unreachable(b1.UniqueAddress, c1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1), new GossipOverview(r1));
            var r2 = Reachability.Empty.Unreachable(a1.UniqueAddress, d1.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);
            
            XAssert.Equivalent(ImmutableHashSet.Create(a1.UniqueAddress, c1.UniqueAddress, d1.UniqueAddress),
                merged1.Overview.Reachability.AllUnreachable);

            var merged2 = g2.Merge(g1);
            XAssert.Equivalent(merged1.Overview.Reachability.AllUnreachable,
                merged2.Overview.Reachability.AllUnreachable
                );
        }
Exemplo n.º 5
0
        public void A_gossip_must_merge_unreachable()
        {
            var r1 = Reachability.Empty.
                     Unreachable(b1.UniqueAddress, a1.UniqueAddress).
                     Unreachable(b1.UniqueAddress, c1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1), new GossipOverview(r1));
            var r2 = Reachability.Empty.Unreachable(a1.UniqueAddress, d1.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);

            merged1.Overview.Reachability.AllUnreachable.Should()
            .BeEquivalentTo(ImmutableHashSet.Create(a1.UniqueAddress, c1.UniqueAddress, d1.UniqueAddress));

            var merged2 = g2.Merge(g1);

            merged2.Overview.Reachability.AllUnreachable.Should()
            .BeEquivalentTo(merged1.Overview.Reachability.AllUnreachable);
        }
Exemplo n.º 6
0
        public void AGossipMustMergeMembersByRemovingRemovedMembers()
        {
            // c3 removed
            var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1), new GossipOverview(r1));
            var r2 = r1.Unreachable(b1.UniqueAddress, c3.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c3), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);

            Assert.Equal(ImmutableHashSet.Create(a1, b1), merged1.Members);
            Assert.Equal(ImmutableHashSet.Create(a1.UniqueAddress), merged1.Overview.Reachability.AllUnreachable);


            var merged2 = g2.Merge(g1);

            Assert.Equal(merged2.Overview.Reachability.AllUnreachable, merged1.Overview.Reachability.AllUnreachable);
            Assert.Equal(merged1.Members, merged2.Members);
        }
Exemplo n.º 7
0
        public void AGossipMustMergeUnreachable()
        {
            var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress)
                     .Unreachable(b1.UniqueAddress, c1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1), new GossipOverview(r1));
            var r2 = Reachability.Empty.Unreachable(a1.UniqueAddress, d1.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);

            XAssert.Equivalent(ImmutableHashSet.Create(a1.UniqueAddress, c1.UniqueAddress, d1.UniqueAddress),
                               merged1.Overview.Reachability.AllUnreachable);

            var merged2 = g2.Merge(g1);

            XAssert.Equivalent(merged1.Overview.Reachability.AllUnreachable,
                               merged2.Overview.Reachability.AllUnreachable
                               );
        }
Exemplo n.º 8
0
        public void A_gossip_must_merge_members_by_removing_removed_members()
        {
            // c3 removed
            var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1), new GossipOverview(r1));
            var r2 = r1.Unreachable(b1.UniqueAddress, c3.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c3), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);

            merged1.Members.Should().BeEquivalentTo(ImmutableHashSet.Create(a1, b1));
            merged1.Overview.Reachability.AllUnreachable.Should()
            .BeEquivalentTo(ImmutableHashSet.Create(a1.UniqueAddress));

            var merged2 = g2.Merge(g1);

            merged2.Overview.Reachability.AllUnreachable.Should()
            .BeEquivalentTo(merged1.Overview.Reachability.AllUnreachable);
            merged2.Members.Should().BeEquivalentTo(merged1.Members);
        }
Exemplo n.º 9
0
        public void AGossipMustMergeSeenTableCorrectly()
        {
            var vclockNode = VectorClock.Node.Create("something");
            var g1 =
                new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                    .Seen(a1.UniqueAddress)
                    .Seen(b1.UniqueAddress);
            var g2 =
                new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                    .Seen(a1.UniqueAddress)
                    .Seen(c1.UniqueAddress);
            var g3 = g1.Copy(version: g2.Version).Seen(d1.UniqueAddress);

            Action<Gossip> checkMerge = (m) =>
            {
                var seen = m.Overview.Seen;
                Assert.Equal(0, seen.Count());

                Assert.False(m.SeenByNode(a1.UniqueAddress));
                Assert.False(m.SeenByNode(b1.UniqueAddress));
                Assert.False(m.SeenByNode(c1.UniqueAddress));
                Assert.False(m.SeenByNode(d1.UniqueAddress));
                Assert.False(m.SeenByNode(e1.UniqueAddress));
            };

            checkMerge(g3.Merge(g2));
            checkMerge(g2.Merge(g3));
        }
Exemplo n.º 10
0
        public void A_gossip_must_merge_seen_table_correctly()
        {
            var vclockNode = VectorClock.Node.Create("something");
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                    .Seen(a1.UniqueAddress)
                    .Seen(b1.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode)
                    .Seen(a1.UniqueAddress)
                    .Seen(c1.UniqueAddress);
            var g3 = g1.Copy(version: g2.Version).Seen(d1.UniqueAddress);

            Action<Gossip> checkMerge = merged =>
            {
                var seen = merged.Overview.Seen;
                seen.Count.Should().Be(0);

                merged.SeenByNode(a1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(b1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(c1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(d1.UniqueAddress).Should().BeFalse();
                merged.SeenByNode(e1.UniqueAddress).Should().BeFalse();
            };

            checkMerge(g3.Merge(g2));
            checkMerge(g2.Merge(g3));
        }
Exemplo n.º 11
0
        public void A_gossip_must_merge_members_by_removing_removed_members()
        {
            // c3 removed
            var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1), new GossipOverview(r1));
            var r2 = r1.Unreachable(b1.UniqueAddress, c3.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c3), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);
            merged1.Members.Should().BeEquivalentTo(ImmutableHashSet.Create(a1, b1));
            merged1.Overview.Reachability.AllUnreachable.Should()
                .BeEquivalentTo(ImmutableHashSet.Create(a1.UniqueAddress));

            var merged2 = g2.Merge(g1);
            merged2.Overview.Reachability.AllUnreachable.Should()
                .BeEquivalentTo(merged1.Overview.Reachability.AllUnreachable);
            merged2.Members.Should().BeEquivalentTo(merged1.Members);
        }
Exemplo n.º 12
0
        public void A_gossip_must_merge_unreachable()
        {
            var r1 = Reachability.Empty.
                Unreachable(b1.UniqueAddress, a1.UniqueAddress).
                Unreachable(b1.UniqueAddress, c1.UniqueAddress);
            var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1), new GossipOverview(r1));
            var r2 = Reachability.Empty.Unreachable(a1.UniqueAddress, d1.UniqueAddress);
            var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1), new GossipOverview(r2));

            var merged1 = g1.Merge(g2);
            merged1.Overview.Reachability.AllUnreachable.Should()
                .BeEquivalentTo(ImmutableHashSet.Create(a1.UniqueAddress, c1.UniqueAddress, d1.UniqueAddress));
            
            var merged2 = g2.Merge(g1);
            merged2.Overview.Reachability.AllUnreachable.Should()
                .BeEquivalentTo(merged1.Overview.Reachability.AllUnreachable);
        }