mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
wip: removed some debug statements and all tests passing on my PC...feel there is something wrong with the service discovery test around task execution not completing
This commit is contained in:
parent
fb0f101732
commit
932bcb73d4
@ -32,16 +32,14 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
|||||||
|
|
||||||
public Response Add(string key, ILoadBalancer loadBalancer)
|
public Response Add(string key, ILoadBalancer loadBalancer)
|
||||||
{
|
{
|
||||||
try
|
if (!_loadBalancers.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_loadBalancers.Add(key, loadBalancer);
|
_loadBalancers.Add(key, loadBalancer);
|
||||||
|
}
|
||||||
|
|
||||||
|
_loadBalancers.Remove(key);
|
||||||
|
_loadBalancers.Add(key, loadBalancer);
|
||||||
return new OkResponse();
|
return new OkResponse();
|
||||||
}
|
}
|
||||||
catch (System.Exception exception)
|
|
||||||
{
|
|
||||||
Console.WriteLine(exception.StackTrace);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,9 @@ namespace Ocelot.AcceptanceTests
|
|||||||
private IWebHost _builderTwo;
|
private IWebHost _builderTwo;
|
||||||
private IWebHost _fakeConsulBuilder;
|
private IWebHost _fakeConsulBuilder;
|
||||||
private readonly Steps _steps;
|
private readonly Steps _steps;
|
||||||
private List<ServiceEntry> _serviceEntries;
|
private readonly List<ServiceEntry> _serviceEntries;
|
||||||
private int _counterOne;
|
private int _counterOne;
|
||||||
private int _counterTwo;
|
private int _counterTwo;
|
||||||
private static readonly object _syncLock = new object();
|
|
||||||
|
|
||||||
public ServiceDiscoveryTests()
|
public ServiceDiscoveryTests()
|
||||||
{
|
{
|
||||||
@ -101,8 +100,8 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
private void ThenBothServicesCalledRealisticAmountOfTimes()
|
private void ThenBothServicesCalledRealisticAmountOfTimes()
|
||||||
{
|
{
|
||||||
_counterOne.ShouldBeGreaterThan(25);
|
_counterOne.ShouldBe(25);
|
||||||
_counterTwo.ShouldBeGreaterThan(25);
|
_counterTwo.ShouldBe(25);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThenTheTwoServicesShouldHaveBeenCalledTimes(int expected)
|
private void ThenTheTwoServicesShouldHaveBeenCalledTimes(int expected)
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
{
|
{
|
||||||
var runTime = $"{oSDescription}-{osArchitecture}".ToLower();
|
var runTime = $"{oSDescription}-{osArchitecture}".ToLower();
|
||||||
|
|
||||||
var configPath = $"./test/Ocelot.AcceptanceTests/bin/Debug/netcoreapp{Version}/{runTime}/configuration.json";
|
var configPath = $"./bin/Debug/netcoreapp{Version}/{runTime}/configuration.json";
|
||||||
|
|
||||||
return configPath;
|
return configPath;
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
_leastConnection = new LeastConnectionLoadBalancer(() => Task.FromResult(_services), serviceName);
|
_leastConnection = new LeastConnectionLoadBalancer(() => Task.FromResult(_services), serviceName);
|
||||||
|
|
||||||
var tasks = new Task[100];
|
var tasks = new Task[100];
|
||||||
try
|
|
||||||
{
|
|
||||||
for(var i = 0; i < tasks.Length; i++)
|
for(var i = 0; i < tasks.Length; i++)
|
||||||
{
|
{
|
||||||
tasks[i] = LeaseDelayAndRelease();
|
tasks[i] = LeaseDelayAndRelease();
|
||||||
@ -47,12 +46,6 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
|
|
||||||
Task.WaitAll(tasks);
|
Task.WaitAll(tasks);
|
||||||
}
|
}
|
||||||
catch (System.Exception exception)
|
|
||||||
{
|
|
||||||
Console.WriteLine(exception.StackTrace);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task LeaseDelayAndRelease()
|
private async Task LeaseDelayAndRelease()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user