mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 18:22:49 +08:00
wip: modifications to service discovery acceptance test to see if it will work on mac
This commit is contained in:
parent
932bcb73d4
commit
d91242ac2c
@ -41,7 +41,7 @@ touch either via gitter or create an issue.
|
|||||||
## How to install
|
## How to install
|
||||||
|
|
||||||
Ocelot is designed to work with ASP.NET core only and is currently
|
Ocelot is designed to work with ASP.NET core only and is currently
|
||||||
built to netcoreapp1.4 [this](https://docs.microsoft.com/en-us/dotnet/articles/standard/library) documentation may prove helpful when working out if Ocelot would be suitable for you.
|
built to netcoreapp1.1 [this](https://docs.microsoft.com/en-us/dotnet/articles/standard/library) documentation may prove helpful when working out if Ocelot would be suitable for you.
|
||||||
|
|
||||||
Install Ocelot and it's dependecies using nuget. At the moment
|
Install Ocelot and it's dependecies using nuget. At the moment
|
||||||
all we have is the pre version. Once we have something working in
|
all we have is the pre version. Once we have something working in
|
||||||
|
@ -22,6 +22,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
private readonly 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()
|
||||||
{
|
{
|
||||||
@ -152,9 +153,15 @@ namespace Ocelot.AcceptanceTests
|
|||||||
.Configure(app =>
|
.Configure(app =>
|
||||||
{
|
{
|
||||||
app.Run(async context =>
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
var response = string.Empty;
|
||||||
|
lock (_syncLock)
|
||||||
{
|
{
|
||||||
_counterOne++;
|
_counterOne++;
|
||||||
|
response = _counterOne.ToString();
|
||||||
|
}
|
||||||
context.Response.StatusCode = statusCode;
|
context.Response.StatusCode = statusCode;
|
||||||
|
await context.Response.WriteAsync(response);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
@ -173,9 +180,15 @@ namespace Ocelot.AcceptanceTests
|
|||||||
.Configure(app =>
|
.Configure(app =>
|
||||||
{
|
{
|
||||||
app.Run(async context =>
|
app.Run(async context =>
|
||||||
|
{
|
||||||
|
var response = string.Empty;
|
||||||
|
lock (_syncLock)
|
||||||
{
|
{
|
||||||
_counterTwo++;
|
_counterTwo++;
|
||||||
|
response = _counterTwo.ToString();
|
||||||
|
}
|
||||||
context.Response.StatusCode = statusCode;
|
context.Response.StatusCode = statusCode;
|
||||||
|
await context.Response.WriteAsync(response);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.Build();
|
.Build();
|
||||||
|
@ -160,12 +160,21 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
for (int i = 0; i < times; i++)
|
for (int i = 0; i < times; i++)
|
||||||
{
|
{
|
||||||
tasks[i] = _ocelotClient.GetAsync(url);
|
var urlCopy = url;
|
||||||
|
tasks[i] = GetForServiceDiscoveryTest(urlCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.WaitAll(tasks);
|
Task.WaitAll(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task GetForServiceDiscoveryTest(string url)
|
||||||
|
{
|
||||||
|
var response = await _ocelotClient.GetAsync(url);
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
var count = int.Parse(content);
|
||||||
|
count.ShouldBeGreaterThan(0);
|
||||||
|
}
|
||||||
|
|
||||||
public void WhenIGetUrlOnTheApiGateway(string url, string requestId)
|
public void WhenIGetUrlOnTheApiGateway(string url, string requestId)
|
||||||
{
|
{
|
||||||
_ocelotClient.DefaultRequestHeaders.TryAddWithoutValidation(RequestIdKey, requestId);
|
_ocelotClient.DefaultRequestHeaders.TryAddWithoutValidation(RequestIdKey, requestId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user