예제 #1
0
        public void If_a_heartbeat_is_missed_the_saga_should_mark_the_endpoint_suspect()
        {
            MakeSagaSuspect();

            HealthSaga saga = GetSaga();

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(HealthSaga.Suspect);
        }
예제 #2
0
        public void Should_publish_heartbeats_to_the_service()
        {
            LocalBus.Publish(new EndpointCameOnline(Guid.NewGuid(), LocalBus.ControlBus.Endpoint.Address.Uri, LocalBus.Endpoint.Address.Uri,
                                                    0));

            HealthSaga saga = GetSaga();

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(HealthSaga.Healthy);
        }
예제 #3
0
        public void The_HealthClient_should_publish_heartbeats()
        {
            LocalBus.Publish(new EndpointCameOnline(_id, LocalBus.ControlBus.Endpoint.Uri, LocalBus.Endpoint.Uri, 0));
            Thread.Sleep(500);

            HealthSaga saga = Repository.Where(x => x.CorrelationId == _id).FirstOrDefault();

            saga.ShouldNotBeNull();
            saga.CurrentState.ShouldEqual(HealthSaga.Healthy);
        }
예제 #4
0
        public void If_a_saga_is_suspect_a_heartbeat_should_fix()
        {
            MakeSagaSuspect();

            HealthSaga saga = GetSaga();

            LocalBus.Publish(new Heartbeat(saga.CorrelationId, LocalBus.ControlBus.Endpoint.Address.Uri, LocalBus.Endpoint.Address.Uri, 0));

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(HealthSaga.Healthy);
        }
예제 #5
0
        public void If_endpoint_down_a_heartbeat_should_revive()
        {
            MakeSagaDown();

            HealthSaga saga = GetSaga();

            LocalBus.Publish(new Heartbeat(saga.CorrelationId, LocalBus.ControlBus.Endpoint.Address.Uri, LocalBus.Endpoint.Address.Uri, 0));

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(HealthSaga.Healthy);
        }
예제 #6
0
        public void If_a_saga_is_suspect_a_pingtimeout_should_make_it_down()
        {
            MakeSagaSuspect();

            HealthSaga saga = GetSaga();

            LocalBus.Publish(new TimeoutExpired {
                CorrelationId = saga.CorrelationId, Tag = 2
            });

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(HealthSaga.Down);
        }
예제 #7
0
        void MakeSagaDown()
        {
            MakeSagaSuspect();

            HealthSaga saga = GetSaga();

            LocalBus.Publish(new TimeoutExpired {
                CorrelationId = saga.CorrelationId, Tag = 2
            });

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(HealthSaga.Down);
        }
예제 #8
0
        public void MakeSagaSuspect()
        {
            LocalBus.Publish(new EndpointCameOnline(Guid.NewGuid(), LocalBus.ControlBus.Endpoint.Address.Uri, LocalBus.Endpoint.Address.Uri,
                                                    0));

            HealthSaga saga = GetSaga();

            saga.ShouldNotBeNull();
            saga.ShouldBeInState(HealthSaga.Healthy);

            LocalBus.Publish(new TimeoutExpired {
                CorrelationId = saga.CorrelationId, Tag = 1
            });

            saga.ShouldBeInState(HealthSaga.Suspect);
        }