Skip to content
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
123c6e8
chore: Ocelot.Configuration.Creator.IHttpHandlerOptionsCreator => Upd…
henriqueholtz Sep 28, 2024
07c024c
chore: Getting rid of ".Result" (using "GetAwaiter().GetResult()" ins…
henriqueholtz Sep 28, 2024
cc37929
test: Getting rid of ".Result" (using "GetAwaiter().GetResult()" inst…
henriqueholtz Sep 28, 2024
d5bc104
chore: Benchmarks => Turning "await app.UseOcelot()" instead of of "a…
henriqueholtz Sep 28, 2024
9b9ec8c
test: Turning "await app.UseOcelot()" instead of of "app.UseOcelot().…
henriqueholtz Sep 28, 2024
fae4354
test: Ocelot.IntegrationTests.AdministrationTests => Turning methods …
henriqueholtz Oct 1, 2024
877814c
perf: Ocelot.UnitTests => Getting rid of "GetAwaiter().GetResult" and…
henriqueholtz Oct 1, 2024
4c06622
test: Ocelot.AcceptanceTests => turning methods as async as possible
henriqueholtz Oct 2, 2024
f095153
test: Fixing the test "should_return_response_200_with_simple_url_whe…
henriqueholtz Oct 2, 2024
2031123
test: Fixing tests from "ConsulConfigurationInConsulTests" + async/aw…
henriqueholtz Oct 2, 2024
551d1b7
test: Fixing some tests after merging
henriqueholtz Oct 5, 2024
ebd5dcb
test: Ocelot.AcceptanceTests => Using asyn/await instead of ".GetAwai…
henriqueholtz Oct 9, 2024
d82f37a
test: Returning the task directly instead of awaiting for it when it'…
henriqueholtz Oct 9, 2024
e708509
test: Undo moving the function "Steps.ThenTheStatusCodeShouldBe(HttpS…
henriqueholtz Oct 9, 2024
4f1ddd1
test: Removing with no usage function "Steps.GivenOcelotIsRunningWith…
henriqueholtz Oct 10, 2024
59bd034
test: Creating method "UntilAsync" and using it to get rid some ".Get…
henriqueholtz Oct 10, 2024
2abdbbf
chore: Reverting renaming (removing the suffix "Async")
henriqueholtz Oct 11, 2024
11c1459
chore: (2th) Reverting renaming (removing the suffix "Async")
henriqueholtz Oct 11, 2024
9bd1214
test: Bringing back the slash I removed with no reason
henriqueholtz Oct 11, 2024
59c3551
chore: Trying to revert fake changes of "test/Ocelot.AcceptanceTests/…
henriqueholtz Oct 12, 2024
63fc393
chore: Undone fake changes
henriqueholtz Oct 12, 2024
61d5436
chore: Undone useless renamed methods
henriqueholtz Oct 12, 2024
056831f
chore: removing unecessary "await task" and just returning it
henriqueholtz Oct 12, 2024
9a6eab8
chore: Undone fake changes "AggregateTests"
henriqueholtz Oct 12, 2024
1cc02f1
chore: FileConfigurationFluentValidatorTests => Undo rename method "W…
henriqueholtz Oct 12, 2024
cb21556
chore: test/Ocelot.AcceptanceTests/AggregateTests => reverting fake c…
henriqueholtz Oct 12, 2024
8343c38
chore: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCa…
henriqueholtz Oct 13, 2024
687a250
test: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCac…
henriqueholtz Oct 13, 2024
9629a94
perf: src/Ocelot.Provider.Consul/Consul => Using async/await instead …
henriqueholtz Oct 13, 2024
b6c3d82
chore: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCa…
henriqueholtz Oct 13, 2024
a38f733
Revert "chore: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewa…
henriqueholtz Oct 13, 2024
0c1b38b
Revert "test: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewar…
henriqueholtz Oct 13, 2024
6896aaf
test: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCac…
henriqueholtz Oct 13, 2024
a9659ed
perf: ConsulFileConfigurationPollerOption.GetDelay => Removing useles…
henriqueholtz Oct 13, 2024
480ba72
chore: Ocelot.UnitTests.Configuration.FileConfigurationSetterTests =>…
henriqueholtz Oct 15, 2024
3655677
Revert "chore: Ocelot.UnitTests.Configuration.FileConfigurationSetter…
henriqueholtz Oct 15, 2024
b11b8ee
Fix build errors
raman-m Oct 16, 2024
a851098
EOL: test/Ocelot.AcceptanceTests/AggregateTests.cs
raman-m Oct 16, 2024
5ea8c89
code review by @raman-m
raman-m Oct 16, 2024
efd5a31
EOL: test/Ocelot.AcceptanceTests/Steps.cs
raman-m Oct 16, 2024
16e495f
Fix build
raman-m Oct 16, 2024
8061814
EOL: test/Ocelot.IntegrationTests/CacheManagerTests.cs
raman-m Oct 16, 2024
5c03c96
EOL: test/Ocelot.IntegrationTests/HeaderTests.cs
raman-m Oct 16, 2024
943d9bb
EOL: test/Ocelot.UnitTests/Configuration/Validation/FileConfiguration…
raman-m Oct 16, 2024
93331c7
EOL: test/Ocelot.UnitTests/Requester/HttpRequesterMiddlewareTests.cs
raman-m Oct 16, 2024
cc4a920
EOL: test/Ocelot.UnitTests/Security/SecurityMiddlewareTests.cs
raman-m Oct 16, 2024
8b10792
Revert the code to read `ValueTask.Result` if completed.
raman-m Oct 16, 2024
6ff1011
Sync call of the async method inside of sync context.
raman-m Oct 16, 2024
5376507
Add docs for Dev Best Practices
raman-m Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Ocelot.Provider.Consul/Consul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public virtual async Task<List<Service>> GetAsync()
var nodesTask = _consul.Catalog.Nodes();

await Task.WhenAll(entriesTask, nodesTask);

var entries = entriesTask.Result.Response ?? Array.Empty<ServiceEntry>();
var nodes = nodesTask.Result.Response ?? Array.Empty<Node>();
var entries = (await entriesTask).Response ?? Array.Empty<ServiceEntry>();
var nodes = (await nodesTask).Response ?? Array.Empty<Node>();
if (entries.Length == 0)
{
_logger.LogWarning(() => $"{nameof(Consul)} Provider: No service entries found for '{_configuration.KeyOfServiceInConsul}' service!");
Expand Down
2 changes: 1 addition & 1 deletion src/Ocelot.Provider.Consul/PollConsul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Task<List<Service>> GetAsync()
try
{
_logger.LogInformation(() => $"Retrieving new client information for service: {ServiceName}...");
_services = _consulServiceDiscoveryProvider.GetAsync().Result;
_services = _consulServiceDiscoveryProvider.GetAsync().GetAwaiter().GetResult();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are within a lock statement, we must adhere to writing only synchronous code. I agree with the change, however...
@ggnaegi, what would occur if we eliminate the lock? Due to the need for precise time capturing, we must prevent other threads from executing because the method modifies the class member _lastUpdateTime on line 59. It appears it's not feasible to convert this method into truly asynchronous, correct?

Copy link
Member

@raman-m raman-m Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue!.. We will tackle the issue of lock statements versus synchronous task calls in the future.

return Task.FromResult(_services);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace Ocelot.Configuration.Creator
/// </summary>
public interface IHttpHandlerOptionsCreator
{
HttpHandlerOptions Create(FileHttpHandlerOptions fileRoute);
HttpHandlerOptions Create(FileHttpHandlerOptions options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private int GetDelay()
{
var delay = 1000;

var fileConfig = Task.Run(async () => await _fileConfigurationRepository.Get()).Result;
var fileConfig = _fileConfigurationRepository.Get().GetAwaiter().GetResult();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this sync version in the interface:


Why not to add async version to the interface?
After that we can make private and public methods as true async → Task<int> DelayAsync { get; }

Suggested change
var fileConfig = _fileConfigurationRepository.Get().GetAwaiter().GetResult();
var fileConfig = await _fileConfigurationRepository.Get();

Optional goal is using Task.Delay, if applicable.

Copy link
Member

@raman-m raman-m Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expression has been revised to execute synchronously within the synchronous int GetDelay() method.
The proposed suggestion for refactoring is beyond the scope of this pull request. We will refactor the interface in future.
TODO added in commit 6ff1011 ✔️

if (fileConfig?.Data?.GlobalConfiguration?.ServiceDiscoveryProvider != null &&
!fileConfig.IsError &&
fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval > 0)
Expand Down
2 changes: 1 addition & 1 deletion src/Ocelot/Request/Mapper/StreamHttpContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static async Task CopyAsync(Stream input, Stream output, long announcedC
if (zeroByteReadTask.IsCompletedSuccessfully)
{
// Consume the ValueTask's result in case it is backed by an IValueTaskSource
_ = zeroByteReadTask.Result;
_ = zeroByteReadTask.GetAwaiter().GetResult();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion test/Ocelot.AcceptanceTests/AggregateTests.cs
Copy link
Member

@raman-m raman-m Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my gosh! 🤯 👇 700 lines of fake changes!
Can't you make manual changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advice: Copy a clean file from the develop branch in the upstream repository (which requires another copy of the upstream repo), and then apply your 2-3 line change. This is a straightforward manual modification, but it is always effective.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raman-m I was trying to figure out why those "fake changes" even though we have the .editorconfig in place.

Note: the right version is CRLF (as it's in .editorconfig file).

Those "fake changes" are because some lines at these files are still as LF (incorrect!). It means that these changes are actually the correct way to do (I know it let the PR longer/harder to review).

Are you aware of that? Should I undo it even though ? It's important to point out that any person who touch these files using an IDE like VS or VS Code will hit the same problem.

Basically if I undo these "fake changes", when someone else touch these files they'll face the same issue. Considering the long way to the repo please consider that we should keep the changes as the .editorconfig say. Take a look at the example below.

Also you can just try to do that on your machine and see/confirm it.

Example test/Ocelot.UnitTests/Configuration/FileConfigurationSetterTests.cs:

image

Copy link
Member

@raman-m raman-m Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to figure out why those "fake changes" even though we have the .editorconfig in place.

I've detailed the root cause of fictitious ("fake") changes here: they are the result of auto-refactoring commands in IDEs such as Visual Studio, Visual Code, Rider, and others.

Those "fake changes" are because some lines at these files are still as LF (incorrect!). It means that these changes are actually the correct way to do (I know it let the PR longer/harder to review).

This issue has persisted since the project's inception in 2016!
Indeed, some lines end with the LF character from the Linux OS. Several of our contributors work on Linux and use IDEs like Visual Code, where the default newline character is LF. Consequently, we have numerous files with inconsistent EOL characters. Do you code on Linux or Windows?
I suggest using Windows to avoid the end-of-line (EOL) issue. ❗

Are you aware of that? Should I undo it even though ? It's important to point out that any person who touch these files using an IDE like VS or VS Code will hit the same problem.

Yes, I am! What are you trying to teach me, man? I've been aware of this issue for over a year.
You'll encounter the problem if you use Linux OS.
Boot into Windows, use Visual Studio Community (it's free), avoid using auto-refactoring commands, and everything will work out fine.

Basically if I undo these "fake changes", when someone else touch these files they'll face the same issue. Considering the long way to the repo please consider that we should keep the changes as the .editorconfig say. Take a look at the example below.

It's irrelevant! The likelihood of encountering this issue remains unchanged. We cannot foresee which operating system the subsequent developer might use. The concern is not regarding future developers, but rather about your current development environment.
If your PR contains numerous artificial changes aka "fake changes", it increases the chances that subsequent developers will encounter this issue. Therefore, I request the removal of all such changes due to end-of-line characters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit a851098 ✔️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got the same issue using Windows (VS and VS Code), but also using linux. That's because I asked you gently, while I was trying to help. You was totally rough with no reason to act like that.

Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ private void GivenOcelotIsRunningWithSpecificAggregatorsRegisteredInDi<TAggregat
s.AddOcelot()
.AddSingletonDefinedAggregator<TAggregator>();
})
.Configure(a => { a.UseOcelot().Wait(); });
.Configure(async b => await b.UseOcelot());

_ocelotServer = new TestServer(_webHostBuilder);
_ocelotClient = _ocelotServer.CreateClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public void Should_return_201_using_identity_server_reference_token()
}

[IgnorePublicMethod]
public void GivenThereIsAnIdentityServerOn(string url, AccessTokenType tokenType)
public async Task GivenThereIsAnIdentityServerOn(string url, AccessTokenType tokenType)
{
var scopes = new string[] { "api", "api2" };
_identityServerBuilder = CreateIdentityServer(url, tokenType, scopes, null)
.Build();
_identityServerBuilder.Start();
VerifyIdentityServerStarted(url);
await _identityServerBuilder.StartAsync();
await VerifyIdentityServerStarted(url);
}

public override void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private MultipleAuthSchemesFeatureTests GivenIdentityServerWithScopes(int index,

var server = _identityServers[index] = builder.Build();
server.Start();
VerifyIdentityServerStarted(url);
VerifyIdentityServerStarted(url).GetAwaiter().GetResult();
return this;
}

Expand Down
12 changes: 6 additions & 6 deletions test/Ocelot.AcceptanceTests/AuthorizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void GivenThereIsAServiceRunningOn(string url, int statusCode, string re
});
}

private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType)
private async Task GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType)
{
_identityServerBuilder = new WebHostBuilder()
.UseUrls(url)
Expand Down Expand Up @@ -390,12 +390,12 @@ private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTo
})
.Build();

_identityServerBuilder.Start();
await _identityServerBuilder.StartAsync();

Steps.VerifyIdentityServerStarted(url);
await Steps.VerifyIdentityServerStarted(url);
}

private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, List<TestUser> users)
private async Task GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, List<TestUser> users)
{
_identityServerBuilder = new WebHostBuilder()
.UseUrls(url)
Expand Down Expand Up @@ -461,9 +461,9 @@ private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTo
})
.Build();

_identityServerBuilder.Start();
await _identityServerBuilder.StartAsync();

Steps.VerifyIdentityServerStarted(url);
await Steps.VerifyIdentityServerStarted(url);
}

private async Task GivenIHaveATokenForApiReadOnlyScope(string url)
Expand Down
6 changes: 3 additions & 3 deletions test/Ocelot.AcceptanceTests/ClaimsToDownstreamPathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private void GivenThereIsAServiceRunningOn(string url, int statusCode)
_servicebuilder.Start();
}

private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
private async Task GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
{
_identityServerBuilder = new WebHostBuilder()
.UseUrls(url)
Expand Down Expand Up @@ -194,9 +194,9 @@ private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTo
})
.Build();

_identityServerBuilder.Start();
await _identityServerBuilder.StartAsync();

Steps.VerifyIdentityServerStarted(url);
await Steps.VerifyIdentityServerStarted(url);
}

public void Dispose()
Expand Down
6 changes: 3 additions & 3 deletions test/Ocelot.AcceptanceTests/ClaimsToHeadersForwardingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void GivenThereIsAServiceRunningOn(string url, int statusCode)
});
}

private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
private async Task GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
{
_identityServerBuilder = new WebHostBuilder()
.UseUrls(url)
Expand Down Expand Up @@ -188,9 +188,9 @@ private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTo
})
.Build();

_identityServerBuilder.Start();
await _identityServerBuilder.StartAsync();

Steps.VerifyIdentityServerStarted(url);
await Steps.VerifyIdentityServerStarted(url);
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private void GivenThereIsAServiceRunningOn(string url, int statusCode)
_servicebuilder.Start();
}

private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
private async Task GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTokenType tokenType, TestUser user)
{
_identityServerBuilder = new WebHostBuilder()
.UseUrls(url)
Expand Down Expand Up @@ -275,9 +275,9 @@ private void GivenThereIsAnIdentityServerOn(string url, string apiName, AccessTo
})
.Build();

_identityServerBuilder.Start();
await _identityServerBuilder.StartAsync();

Steps.VerifyIdentityServerStarted(url);
await Steps.VerifyIdentityServerStarted(url);
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void should_return_response_200_with_simple_url_when_using_jsonserialized
.BDDfy();
}

private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string serviceName)
private Task GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string serviceName)
{
_fakeConsulBuilder = Host.CreateDefaultBuilder()
.ConfigureWebHost(webBuilder =>
Expand Down Expand Up @@ -128,8 +128,7 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string
});
});
}).Build();

_fakeConsulBuilder.Start();
return _fakeConsulBuilder.StartAsync();
}

public class FakeConsulGetResponse
Expand All @@ -148,7 +147,7 @@ public FakeConsulGetResponse(string value)
public string Session => "adf4238a-882b-9ddc-4a9d-5b6758e4159e";
}

private void GivenThereIsAServiceRunningOn(string url, string basePath, int statusCode, string responseBody)
private Task GivenThereIsAServiceRunningOn(string url, string basePath, int statusCode, string responseBody)
{
_builder = Host.CreateDefaultBuilder()
.ConfigureWebHost(webBuilder =>
Expand All @@ -169,8 +168,7 @@ private void GivenThereIsAServiceRunningOn(string url, string basePath, int stat
});
})
.Build();

_builder.Start();
return _builder.StartAsync();
}

public void Dispose()
Expand Down
28 changes: 10 additions & 18 deletions test/Ocelot.AcceptanceTests/OpenTracingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public static Waiter WaitFor(int milliSeconds)
}
}

public class Waiter
public class Waiter // TODO Move to Ocelot.Testing project
{
private readonly int _milliSeconds;

Expand All @@ -524,36 +524,27 @@ public Waiter(int milliSeconds)
_milliSeconds = milliSeconds;
}

// TODO Replace with async version in tests
public bool Until(Func<bool> condition)
{
var stopwatch = Stopwatch.StartNew();
var passed = false;
while (stopwatch.ElapsedMilliseconds < _milliSeconds)
{
if (condition.Invoke())
{
passed = true;
break;
}
}

return passed;
Task<bool> WrappedCondition() => Task.FromResult(condition.Invoke());
return UntilAsync(WrappedCondition).GetAwaiter().GetResult();
}

public async Task<bool> Until(Func<Task<bool>> condition)
public async Task<bool> UntilAsync(Func<Task<bool>> condition)
{
var stopwatch = Stopwatch.StartNew();
var passed = false;
while (stopwatch.ElapsedMilliseconds < _milliSeconds)
{
if (await condition.Invoke())
{
passed = true;
break;
stopwatch.Stop();
return true;
}
}

return passed;
stopwatch.Stop();
return false;
}

public bool Until<T>(Func<bool> condition)
Expand All @@ -569,6 +560,7 @@ public bool Until<T>(Func<bool> condition)
}
}

stopwatch.Stop();
return passed;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public void Should_wait_for_period_timespan_to_elapse_before_making_next_request
private int Count() => ++_count;
private string Url() => $"/ClientRateLimit/?{Count()}";

private void WhenIGetUrlOnTheApiGatewayMultipleTimesForRateLimit(Func<string> urlDelegate, long times)
private async Task WhenIGetUrlOnTheApiGatewayMultipleTimesForRateLimit(Func<string> urlDelegate, long times)
{
for (long i = 0; i < times; i++)
{
var url = urlDelegate.Invoke();
WhenIGetUrlOnTheApiGatewayMultipleTimesForRateLimit(url, 1);
await WhenIGetUrlOnTheApiGatewayMultipleTimesForRateLimit(url, 1);
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/Ocelot.AcceptanceTests/Requester/PayloadTooLargeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ private void GivenOcelotIsRunningOnKestrelWithCustomBodyMaxSize(long customBodyM
{
s.AddOcelot();
})
.Configure(app =>
.Configure(async app =>
{
app.UseOcelot().Wait();
await app.UseOcelot();
})
.UseUrls("http://localhost:5001");
}).Build();
Expand Down Expand Up @@ -150,9 +150,9 @@ private void GivenOcelotIsRunningOnHttpSysWithCustomBodyMaxSize(long customBodyM
{
s.AddOcelot();
})
.Configure(app =>
.Configure(async app =>
{
app.UseOcelot().Wait();
await app.UseOcelot();
})
.UseUrls("http://localhost:5001");
}).Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ public void should_handle_request_to_consul_for_downstream_service_and_make_requ
.BDDfy();
}

private void ThenTheConfigIsUpdatedInOcelot()
private async Task ThenTheConfigIsUpdatedInOcelot()
{
var result = Wait.WaitFor(20000).Until(() =>
var result = await Wait.WaitFor(20000).UntilAsync(async () =>
{
try
{
_steps.WhenIGetUrlOnTheApiGateway("/cs/status/awesome");
await _steps.WhenIGetUrlOnTheApiGateway("/cs/status/awesome");
_steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK);
_steps.ThenTheResponseBodyShouldBe("Hello from Laura");
return true;
Expand All @@ -348,7 +348,7 @@ private void GivenTheServicesAreRegisteredWithConsul(params ServiceEntry[] servi
}
}

private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string serviceName)
private Task GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string serviceName)
{
_fakeConsulBuilder = new WebHostBuilder()
.UseUrls(url)
Expand Down Expand Up @@ -404,8 +404,7 @@ private void GivenThereIsAFakeConsulServiceDiscoveryProvider(string url, string
});
})
.Build();

_fakeConsulBuilder.Start();
return _fakeConsulBuilder.StartAsync();
}

public class FakeConsulGetResponse
Expand All @@ -424,7 +423,7 @@ public FakeConsulGetResponse(string value)
public string Session => "adf4238a-882b-9ddc-4a9d-5b6758e4159e";
}

private void GivenThereIsAServiceRunningOn(string url, string basePath, int statusCode, string responseBody)
private Task GivenThereIsAServiceRunningOn(string url, string basePath, int statusCode, string responseBody)
{
_builder = new WebHostBuilder()
.UseUrls(url)
Expand All @@ -443,8 +442,7 @@ private void GivenThereIsAServiceRunningOn(string url, string basePath, int stat
});
})
.Build();

_builder.Start();
return _builder.StartAsync();
}

public void Dispose()
Expand Down
Loading