#604 set use qos based on what we have in docs (#627)

This commit is contained in:
Tom Pallister 2018-09-20 08:04:15 +01:00 committed by GitHub
parent 669ece07b2
commit 388b1fad90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 17 deletions

View File

@ -24,7 +24,7 @@
public string TimeoutStrategy { get; } public string TimeoutStrategy { get; }
public bool UseQos => ExceptionsAllowedBeforeBreaking > 0 && TimeoutValue > 0; public bool UseQos => ExceptionsAllowedBeforeBreaking > 0 || TimeoutValue > 0;
public string Key { get; } public string Key { get; }
} }

View File

@ -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 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; using Responder;
public class DelegatingHandlerHandlerProviderFactoryTests public class DelegatingHandlerHandlerProviderFactoryTests
@ -302,6 +301,26 @@ namespace Ocelot.UnitTests.Requester
.BDDfy(); .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] [Fact]
public void should_log_error_and_return_no_qos_provider_delegate_when_qos_factory_returns_error() public void should_log_error_and_return_no_qos_provider_delegate_when_qos_factory_returns_error()
{ {