diff --git a/src/Ocelot/Configuration/QoSOptions.cs b/src/Ocelot/Configuration/QoSOptions.cs index 3eb907eb..83309c27 100644 --- a/src/Ocelot/Configuration/QoSOptions.cs +++ b/src/Ocelot/Configuration/QoSOptions.cs @@ -24,7 +24,7 @@ public string TimeoutStrategy { get; } - public bool UseQos => ExceptionsAllowedBeforeBreaking > 0 && TimeoutValue > 0; + public bool UseQos => ExceptionsAllowedBeforeBreaking > 0 || TimeoutValue > 0; public string Key { get; } } diff --git a/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs b/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs index f63c2f34..b1d0ff7b 100644 --- a/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs +++ b/test/Ocelot.UnitTests/Requester/DelegatingHandlerHandlerProviderFactoryTests.cs @@ -1,21 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using Microsoft.Extensions.DependencyInjection; -using Moq; -using Ocelot.Configuration; -using Ocelot.Configuration.Builder; -using Ocelot.Errors; -using Ocelot.Logging; -using Ocelot.Requester; -using Ocelot.Requester.QoS; -using Ocelot.Responses; -using Shouldly; -using TestStack.BDDfy; -using Xunit; - namespace Ocelot.UnitTests.Requester { + using System; + using System.Collections.Generic; + using System.Net.Http; + using Microsoft.Extensions.DependencyInjection; + using Moq; + using Ocelot.Configuration; + using Ocelot.Configuration.Builder; + using Ocelot.Errors; + using Ocelot.Logging; + using Ocelot.Requester; + using Ocelot.Requester.QoS; + using Ocelot.Responses; + using Shouldly; + using TestStack.BDDfy; + using Xunit; using Responder; public class DelegatingHandlerHandlerProviderFactoryTests @@ -302,6 +301,26 @@ namespace Ocelot.UnitTests.Requester .BDDfy(); } + [Fact] + public void should_return_provider_with_qos_delegate_when_timeout_value_set() + { + var qosOptions = new QoSOptionsBuilder() + .WithTimeoutValue(1) + .Build(); + + var reRoute = new DownstreamReRouteBuilder() + .WithQosOptions(qosOptions) + .WithHttpHandlerOptions(new HttpHandlerOptions(true, true, false, true)).WithLoadBalancerKey("").Build(); + + this.Given(x => GivenTheFollowingRequest(reRoute)) + .And(x => GivenTheQosFactoryReturns(new FakeQoSHandler())) + .And(x => GivenTheServiceProviderReturnsNothing()) + .When(x => WhenIGet()) + .Then(x => ThenThereIsDelegatesInProvider(1)) + .And(x => ThenItIsQosHandler(0)) + .BDDfy(); + } + [Fact] public void should_log_error_and_return_no_qos_provider_delegate_when_qos_factory_returns_error() {