コード例 #1
0
        public ClusterDomainEventPublisherSpec() : base(Config)
        {
            _memberSubscriber = CreateTestProbe();
            Sys.EventStream.Subscribe(_memberSubscriber.Ref, typeof(ClusterEvent.IMemberEvent));
            Sys.EventStream.Subscribe(_memberSubscriber.Ref, typeof(ClusterEvent.LeaderChanged));
            Sys.EventStream.Subscribe(_memberSubscriber.Ref, typeof(ClusterEvent.ClusterShuttingDown));

            _publisher = Sys.ActorOf(Props.Create<ClusterDomainEventPublisher>());
            _publisher.Tell(new InternalClusterAction.PublishChanges(g0));
            _memberSubscriber.ExpectMsg(new ClusterEvent.MemberUp(aUp));
            _memberSubscriber.ExpectMsg(new ClusterEvent.LeaderChanged(aUp.Address));
        }
コード例 #2
0
        public ClusterDomainEventPublisherSpec()
        {
            _memberSubscriber = CreateTestProbe();
            Sys.EventStream.Subscribe(_memberSubscriber.Ref, typeof(ClusterEvent.IMemberEvent));
            Sys.EventStream.Subscribe(_memberSubscriber.Ref, typeof(ClusterEvent.LeaderChanged));

            _publisher = Sys.ActorOf(Props.Create<ClusterDomainEventPublisher>());
            //TODO: If parent told of exception then test should fail (if not expected in some way)?
            _publisher.Tell(new InternalClusterAction.PublishChanges(g0));
            _memberSubscriber.ExpectMsg(new ClusterEvent.MemberUp(aUp));
            _memberSubscriber.ExpectMsg(new ClusterEvent.LeaderChanged(aUp.Address));
        }
コード例 #3
0
        public PersistentViewSpec()
            : base(Configuration("inmem", "PersistentViewSpec"))
        {
            _prefProbe = CreateTestProbe();
            _viewProbe = CreateTestProbe();

            _pref = ActorOf(() => new TestPersistentActor(Name, _prefProbe.Ref));
            _pref.Tell("a");
            _pref.Tell("b");

            _prefProbe.ExpectMsg("a-1");
            _prefProbe.ExpectMsg("b-2");
        }
コード例 #4
0
 public void ExpectReceivedData(TestProbe handler, int remaining)
 {
     if (remaining > 0)
     {
         var recv = handler.ExpectMsg<Tcp.Received>();
         ExpectReceivedData(handler, remaining - recv.Data.Count);
     }
 }
コード例 #5
0
        private void AwaitMemberUp(TestProbe memberProbe, params RoleName[] nodes)
        {
            if (nodes.Length > 1)
            {
                RunOn(() =>
                {
                    memberProbe.ExpectMsg<ClusterEvent.MemberUp>(TimeSpan.FromSeconds(15)).Member.Address
                        .Should()
                        .Be(GetAddress(nodes.First()));
                }, nodes.Skip(1).ToArray());
            }

            RunOn(() =>
            {
                var roleNodes = nodes.Select(node => GetAddress(node));

                var addresses = memberProbe.ReceiveN(nodes.Length, TimeSpan.FromSeconds(15))
                    .Where(x => x is ClusterEvent.MemberUp)
                    .Select(x => (x as ClusterEvent.MemberUp).Member.Address);

                addresses.Except(roleNodes).Count().Should().Be(0);
            }, nodes.First());

            EnterBarrier(nodes.First().Name + "-up");
        }
コード例 #6
0
        private IEnumerable<ActorPath> CollectRouteePaths(TestProbe probe, IActorRef router, int n)
        {
            List<ActorPath> list = new List<ActorPath>();

            for (var i = 1; i <= n; i++)
            {
                string msg = i.ToString();
                router.Tell(msg, probe.Ref);
                probe.ExpectMsg(msg);
                list.Add(probe.LastSender.Path);
            }

            return list;
        }
コード例 #7
0
        private void AwaitMemberUp(TestProbe memberProbe, params RoleName[] nodes)
        {
            RunOn(() =>
            {
                Assert.Equal(Node(nodes[0]).Address, memberProbe.ExpectMsg<ClusterEvent.MemberUp>(TimeSpan.FromSeconds(15)).Member.Address);
            }, nodes.Skip(1).ToArray());
            RunOn(() =>
            {
                var membersUp = memberProbe.ReceiveN(nodes.Length, TimeSpan.FromSeconds(15))
                    .Where(x => x is ClusterEvent.MemberUp)
                    .Select(x => (x as ClusterEvent.MemberUp).Member.Address)
                    .Distinct()
                    .ToArray();

                Assert.True(nodes.Select(x => Node(x).Address).ToArray().All(x => membersUp.Contains(x)));
            }, nodes[0]);
            EnterBarrier(nodes[0].Name + "-up");
        }