#1115 find available ports to use in acceptance tests

This commit is contained in:
jlukawska
2020-03-06 10:18:21 +01:00
parent 0af49617ee
commit 263f26ed51
37 changed files with 653 additions and 381 deletions

View File

@ -32,6 +32,9 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_with_simple_url_when_using_jsonserialized_cache()
{
int consulPort = RandomPortFinder.GetRandomPort();
int servicePort = RandomPortFinder.GetRandomPort();
var configuration = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -45,7 +48,7 @@ namespace Ocelot.AcceptanceTests
new FileHostAndPort
{
Host = "localhost",
Port = 51779,
Port = servicePort,
}
},
UpstreamPathTemplate = "/",
@ -57,15 +60,15 @@ namespace Ocelot.AcceptanceTests
ServiceDiscoveryProvider = new FileServiceDiscoveryProvider()
{
Host = "localhost",
Port = 9502
Port = consulPort
}
}
};
var fakeConsulServiceDiscoveryUrl = "http://localhost:9502";
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
this.Given(x => GivenThereIsAFakeConsulServiceDiscoveryProvider(fakeConsulServiceDiscoveryUrl, ""))
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51779", "", 200, "Hello from Laura"))
.And(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{servicePort}", "", 200, "Hello from Laura"))
.And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunningUsingConsulToStoreConfigAndJsonSerializedCache())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))