예제 #1
0
 public void EndpointRegistry_must_be_able_to_register_Gated_policy_for_an_address()
 {
     var reg = new EndpointRegistry();
     Assert.Null(reg.WritableEndpointWithPolicyFor(address1));
     reg.RegisterWritableEndpoint(address1, actorA);
     var deadline = Deadline.Now;
     reg.MarkAsFailed(actorA, deadline);
     Assert.Equal(deadline, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf<EndpointManager.Gated>().TimeOfRelease);
     Assert.False(reg.IsReadOnly(actorA));
     Assert.False(reg.IsWritable(actorA));
 }
예제 #2
0
        public void EndpointRegistry_should_overwrite_Quarantine_policy_with_Pass_on_RegisterWritableEndpoint()
        {
            var reg            = new EndpointRegistry();
            var deadline       = Deadline.Now + TimeSpan.FromMinutes(30);
            var quarantinedUid = 42;

            Assert.Null(reg.WritableEndpointWithPolicyFor(address1));
            reg.MarkAsQuarantined(address1, quarantinedUid, deadline);
            Assert.True(reg.IsQuarantined(address1, quarantinedUid));

            var writableUid = 43;

            reg.RegisterWritableEndpoint(address1, TestActor, writableUid, quarantinedUid);
            Assert.True(reg.IsWritable(TestActor));
        }
예제 #3
0
        public void EndpointRegistry_must_be_able_to_register_a_writeable_endpoint_and_policy()
        {
            var reg = new EndpointRegistry();
            Assert.Null(reg.WritableEndpointWithPolicyFor(address1));

            Assert.Equal(actorA, reg.RegisterWritableEndpoint(address1, actorA));

            Assert.IsType<EndpointManager.Pass>(reg.WritableEndpointWithPolicyFor(address1));
            Assert.Equal(actorA, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf<EndpointManager.Pass>().Endpoint);

            Assert.Null(reg.ReadOnlyEndpointFor(address1));
            Assert.True(reg.IsWritable(actorA));
            Assert.False(reg.IsReadOnly(actorA));

            Assert.False(reg.IsQuarantined(address1, 42));
        }
예제 #4
0
        public void EndpointRegistry_must_be_able_to_register_a_writeable_endpoint_and_policy()
        {
            var reg = new EndpointRegistry();

            Assert.Null(reg.WritableEndpointWithPolicyFor(address1));

            Assert.Equal(actorA, reg.RegisterWritableEndpoint(address1, actorA));

            Assert.IsType <EndpointManager.Pass>(reg.WritableEndpointWithPolicyFor(address1));
            Assert.Equal(actorA, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf <EndpointManager.Pass>().Endpoint);

            Assert.Null(reg.ReadOnlyEndpointFor(address1));
            Assert.True(reg.IsWritable(actorA));
            Assert.False(reg.IsReadOnly(actorA));

            Assert.False(reg.IsQuarantined(address1, 42));
        }
예제 #5
0
        public void EndpointRegistry_must_be_able_to_register_writable_and_readonly_endpoint_correctly()
        {
            var reg = new EndpointRegistry();
            Assert.Null(reg.ReadOnlyEndpointFor(address1));
            Assert.Null(reg.WritableEndpointWithPolicyFor(address1));

            Assert.Equal(actorA, reg.RegisterReadOnlyEndpoint(address1, actorA));
            Assert.Equal(actorB, reg.RegisterWritableEndpoint(address1, actorB));

            Assert.Equal(actorA, reg.ReadOnlyEndpointFor(address1));
            Assert.Equal(actorB, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf<EndpointManager.Pass>().Endpoint);

            Assert.False(reg.IsWritable(actorA));
            Assert.True(reg.IsWritable(actorB));

            Assert.True(reg.IsReadOnly(actorA));
            Assert.False(reg.IsReadOnly(actorB));
        }
예제 #6
0
        public void EndpointRegistry_must_be_able_to_register_writable_and_readonly_endpoint_correctly()
        {
            var reg = new EndpointRegistry();

            Assert.Null(reg.ReadOnlyEndpointFor(address1));
            Assert.Null(reg.WritableEndpointWithPolicyFor(address1));

            Assert.Equal(actorA, reg.RegisterReadOnlyEndpoint(address1, actorA));
            Assert.Equal(actorB, reg.RegisterWritableEndpoint(address1, actorB));

            Assert.Equal(actorA, reg.ReadOnlyEndpointFor(address1));
            Assert.Equal(actorB, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf <EndpointManager.Pass>().Endpoint);

            Assert.False(reg.IsWritable(actorA));
            Assert.True(reg.IsWritable(actorB));

            Assert.True(reg.IsReadOnly(actorA));
            Assert.False(reg.IsReadOnly(actorB));
        }
예제 #7
0
        public void EndpointRegistry_must_keep_tombstones_when_removing_an_endpoint()
        {
            var reg = new EndpointRegistry();
            reg.RegisterWritableEndpoint(address1, actorA);
            reg.RegisterWritableEndpoint(address2, actorB);
            var deadline = Deadline.Now;
            reg.MarkAsFailed(actorA, deadline);
            reg.MarkAsQuarantined(address2, 42, deadline);

            reg.UnregisterEndpoint(actorA);
            reg.UnregisterEndpoint(actorB);

            Assert.Equal(deadline, reg.WritableEndpointWithPolicyFor(address1).AsInstanceOf<EndpointManager.Gated>().TimeOfRelease);
            Assert.Equal(deadline, reg.WritableEndpointWithPolicyFor(address2).AsInstanceOf<EndpointManager.Quarantined>().Deadline);
            Assert.Equal(42, reg.WritableEndpointWithPolicyFor(address2).AsInstanceOf<EndpointManager.Quarantined>().Uid);
        }
예제 #8
0
        public void EndpointRegistry_should_prune_outdated_Gated_directives_properly()
        {
            var reg = new EndpointRegistry();
            reg.RegisterWritableEndpoint(address1, actorA);
            reg.RegisterWritableEndpoint(address2, actorB);
            reg.MarkAsFailed(actorA, Deadline.Now);
            var farIntheFuture = Deadline.Now + TimeSpan.FromSeconds(60);
            reg.MarkAsFailed(actorB, farIntheFuture);
            reg.Prune();

            Assert.Null(reg.WritableEndpointWithPolicyFor(address1));
            Assert.Equal(farIntheFuture, reg.WritableEndpointWithPolicyFor(address2).AsInstanceOf<EndpointManager.Gated>().TimeOfRelease);
        }
예제 #9
0
        public void EndpointRegister_should_not_report_endpoint_as_writeable_if_no_Pass_policy()
        {
            var reg = new EndpointRegistry();
            var deadline = Deadline.Now + TimeSpan.FromMinutes(30);
            
            Assert.False(reg.IsWritable(TestActor)); // no policy

            reg.RegisterWritableEndpoint(address1, TestActor, 42, null);
            Assert.True(reg.IsWritable(TestActor)); // pass
            reg.MarkAsFailed(TestActor, deadline); 
            Assert.False(reg.IsWritable(TestActor)); // Gated
            reg.RegisterWritableEndpoint(address1, TestActor, 43, 42); // restarted
            Assert.True(reg.IsWritable(TestActor)); // pass
            reg.MarkAsQuarantined(address1, 43, deadline);
            Assert.False(reg.HasWriteableEndpointFor(address1)); // Quarantined
        }
예제 #10
0
        public void EndpointRegistry_should_overwrite_Gated_policy_with_Pass_on_RegisterWritableEndpoint()
        {
            var reg = new EndpointRegistry();
            var deadline = Deadline.Now + TimeSpan.FromMinutes(30);
            var willBeGated = 42;

            reg.RegisterWritableEndpoint(address1, TestActor, willBeGated, null);
            Assert.NotNull(reg.WritableEndpointWithPolicyFor(address1));
            Assert.True(reg.IsWritable(TestActor));
            reg.MarkAsFailed(TestActor, deadline);
            Assert.False(reg.IsWritable(TestActor));

            var writableUid = 43;
            reg.RegisterWritableEndpoint(address1, TestActor, writableUid, willBeGated);
            Assert.True(reg.IsWritable(TestActor));
        }
예제 #11
0
        public void EndpointRegistry_should_overwrite_Quarantine_policy_with_Pass_on_RegisterWritableEndpoint()
        {
            var reg = new EndpointRegistry();
            var deadline = Deadline.Now + TimeSpan.FromMinutes(30);
            var quarantinedUid = 42;

            Assert.Null(reg.WritableEndpointWithPolicyFor(address1));
            reg.MarkAsQuarantined(address1, quarantinedUid, deadline);
            Assert.True(reg.IsQuarantined(address1, quarantinedUid));

            var writableUid = 43;
            reg.RegisterWritableEndpoint(address1, TestActor, writableUid, quarantinedUid);
            Assert.True(reg.IsWritable(TestActor));
        }