From d91242ac2c2b80d4ab39d4666657d59633dea224 Mon Sep 17 00:00:00 2001 From: TomPallister Date: Sun, 5 Feb 2017 21:35:50 +0000 Subject: [PATCH] wip: modifications to service discovery acceptance test to see if it will work on mac --- README.md | 2 +- .../ServiceDiscoveryTests.cs | 21 +++++++++++++++---- test/Ocelot.AcceptanceTests/Steps.cs | 11 +++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 249a99a3..9d93546d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ touch either via gitter or create an issue. ## How to install 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 all we have is the pre version. Once we have something working in diff --git a/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs b/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs index 2d9d55af..1bc6723a 100644 --- a/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs +++ b/test/Ocelot.AcceptanceTests/ServiceDiscoveryTests.cs @@ -22,6 +22,7 @@ namespace Ocelot.AcceptanceTests private readonly List _serviceEntries; private int _counterOne; private int _counterTwo; + private static readonly object _syncLock = new object(); public ServiceDiscoveryTests() { @@ -152,9 +153,15 @@ namespace Ocelot.AcceptanceTests .Configure(app => { app.Run(async context => - { - _counterOne++; + { + var response = string.Empty; + lock (_syncLock) + { + _counterOne++; + response = _counterOne.ToString(); + } context.Response.StatusCode = statusCode; + await context.Response.WriteAsync(response); }); }) .Build(); @@ -173,9 +180,15 @@ namespace Ocelot.AcceptanceTests .Configure(app => { app.Run(async context => - { - _counterTwo++; + { + var response = string.Empty; + lock (_syncLock) + { + _counterTwo++; + response = _counterTwo.ToString(); + } context.Response.StatusCode = statusCode; + await context.Response.WriteAsync(response); }); }) .Build(); diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs index 666c3256..5d015994 100644 --- a/test/Ocelot.AcceptanceTests/Steps.cs +++ b/test/Ocelot.AcceptanceTests/Steps.cs @@ -160,12 +160,21 @@ namespace Ocelot.AcceptanceTests for (int i = 0; i < times; i++) { - tasks[i] = _ocelotClient.GetAsync(url); + var urlCopy = url; + tasks[i] = GetForServiceDiscoveryTest(urlCopy); } 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) { _ocelotClient.DefaultRequestHeaders.TryAddWithoutValidation(RequestIdKey, requestId);