mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 17:28:16 +08:00
#1115 find available ports to use in acceptance tests
This commit is contained in:
@ -33,10 +33,12 @@
|
||||
[Fact]
|
||||
public void should_use_consul_service_discovery_and_load_balance_request()
|
||||
{
|
||||
var consulPort = 8502;
|
||||
var consulPort = RandomPortFinder.GetRandomPort();
|
||||
var servicePort1 = RandomPortFinder.GetRandomPort();
|
||||
var servicePort2 = RandomPortFinder.GetRandomPort();
|
||||
var serviceName = "product";
|
||||
var downstreamServiceOneUrl = "http://localhost:50881";
|
||||
var downstreamServiceTwoUrl = "http://localhost:50882";
|
||||
var downstreamServiceOneUrl = $"http://localhost:{servicePort1}";
|
||||
var downstreamServiceTwoUrl = $"http://localhost:{servicePort2}";
|
||||
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
|
||||
var serviceEntryOne = new ServiceEntry()
|
||||
{
|
||||
@ -44,7 +46,7 @@
|
||||
{
|
||||
Service = serviceName,
|
||||
Address = "localhost",
|
||||
Port = 50881,
|
||||
Port = servicePort1,
|
||||
ID = Guid.NewGuid().ToString(),
|
||||
Tags = new string[0]
|
||||
},
|
||||
@ -55,7 +57,7 @@
|
||||
{
|
||||
Service = serviceName,
|
||||
Address = "localhost",
|
||||
Port = 50882,
|
||||
Port = servicePort2,
|
||||
ID = Guid.NewGuid().ToString(),
|
||||
Tags = new string[0]
|
||||
},
|
||||
@ -100,9 +102,10 @@
|
||||
[Fact]
|
||||
public void should_handle_request_to_consul_for_downstream_service_and_make_request()
|
||||
{
|
||||
const int consulPort = 8505;
|
||||
int consulPort = RandomPortFinder.GetRandomPort();
|
||||
int servicePort = RandomPortFinder.GetRandomPort();
|
||||
const string serviceName = "web";
|
||||
const string downstreamServiceOneUrl = "http://localhost:8080";
|
||||
string downstreamServiceOneUrl = $"http://localhost:{servicePort}";
|
||||
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
|
||||
var serviceEntryOne = new ServiceEntry()
|
||||
{
|
||||
@ -110,7 +113,7 @@
|
||||
{
|
||||
Service = serviceName,
|
||||
Address = "localhost",
|
||||
Port = 8080,
|
||||
Port = servicePort,
|
||||
ID = "web_90_0_2_224_8080",
|
||||
Tags = new[] { "version-v1" }
|
||||
},
|
||||
@ -154,9 +157,9 @@
|
||||
[Fact]
|
||||
public void should_handle_request_to_consul_for_downstream_service_and_make_request_no_re_routes()
|
||||
{
|
||||
const int consulPort = 8513;
|
||||
int consulPort = RandomPortFinder.GetRandomPort();
|
||||
const string serviceName = "web";
|
||||
const int downstreamServicePort = 8087;
|
||||
int downstreamServicePort = RandomPortFinder.GetRandomPort();
|
||||
var downstreamServiceOneUrl = $"http://localhost:{downstreamServicePort}";
|
||||
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
|
||||
var serviceEntryOne = new ServiceEntry()
|
||||
@ -204,10 +207,10 @@
|
||||
[Fact]
|
||||
public void should_use_consul_service_discovery_and_load_balance_request_no_re_routes()
|
||||
{
|
||||
var consulPort = 8510;
|
||||
var consulPort = RandomPortFinder.GetRandomPort();
|
||||
var serviceName = "product";
|
||||
var serviceOnePort = 50888;
|
||||
var serviceTwoPort = 50889;
|
||||
var serviceOnePort = RandomPortFinder.GetRandomPort();
|
||||
var serviceTwoPort = RandomPortFinder.GetRandomPort();
|
||||
var downstreamServiceOneUrl = $"http://localhost:{serviceOnePort}";
|
||||
var downstreamServiceTwoUrl = $"http://localhost:{serviceTwoPort}";
|
||||
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
|
||||
@ -264,9 +267,10 @@
|
||||
public void should_use_token_to_make_request_to_consul()
|
||||
{
|
||||
var token = "abctoken";
|
||||
var consulPort = 8515;
|
||||
var consulPort = RandomPortFinder.GetRandomPort();
|
||||
var serviceName = "web";
|
||||
var downstreamServiceOneUrl = "http://localhost:8081";
|
||||
var servicePort = RandomPortFinder.GetRandomPort();
|
||||
var downstreamServiceOneUrl = $"http://localhost:{servicePort}";
|
||||
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
|
||||
var serviceEntryOne = new ServiceEntry()
|
||||
{
|
||||
@ -274,7 +278,7 @@
|
||||
{
|
||||
Service = serviceName,
|
||||
Address = "localhost",
|
||||
Port = 8081,
|
||||
Port = servicePort,
|
||||
ID = "web_90_0_2_224_8080",
|
||||
Tags = new[] { "version-v1" }
|
||||
},
|
||||
@ -320,10 +324,12 @@
|
||||
[Fact]
|
||||
public void should_send_request_to_service_after_it_becomes_available_in_consul()
|
||||
{
|
||||
var consulPort = 8501;
|
||||
var consulPort = RandomPortFinder.GetRandomPort();
|
||||
var serviceName = "product";
|
||||
var downstreamServiceOneUrl = "http://localhost:50879";
|
||||
var downstreamServiceTwoUrl = "http://localhost:50880";
|
||||
var servicePort1 = RandomPortFinder.GetRandomPort();
|
||||
var servicePort2 = RandomPortFinder.GetRandomPort();
|
||||
var downstreamServiceOneUrl = $"http://localhost:{servicePort1}";
|
||||
var downstreamServiceTwoUrl = $"http://localhost:{servicePort2}";
|
||||
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
|
||||
var serviceEntryOne = new ServiceEntry()
|
||||
{
|
||||
@ -331,7 +337,7 @@
|
||||
{
|
||||
Service = serviceName,
|
||||
Address = "localhost",
|
||||
Port = 50879,
|
||||
Port = servicePort1,
|
||||
ID = Guid.NewGuid().ToString(),
|
||||
Tags = new string[0]
|
||||
},
|
||||
@ -342,7 +348,7 @@
|
||||
{
|
||||
Service = serviceName,
|
||||
Address = "localhost",
|
||||
Port = 50880,
|
||||
Port = servicePort2,
|
||||
ID = Guid.NewGuid().ToString(),
|
||||
Tags = new string[0]
|
||||
},
|
||||
@ -396,9 +402,9 @@
|
||||
[Fact]
|
||||
public void should_handle_request_to_poll_consul_for_downstream_service_and_make_request()
|
||||
{
|
||||
const int consulPort = 8518;
|
||||
int consulPort = RandomPortFinder.GetRandomPort();
|
||||
const string serviceName = "web";
|
||||
const int downstreamServicePort = 8082;
|
||||
int downstreamServicePort = RandomPortFinder.GetRandomPort();
|
||||
var downstreamServiceOneUrl = $"http://localhost:{downstreamServicePort}";
|
||||
var fakeConsulServiceDiscoveryUrl = $"http://localhost:{consulPort}";
|
||||
var serviceEntryOne = new ServiceEntry()
|
||||
|
Reference in New Issue
Block a user