public void should_forward_tracing_information_from_ocelot_and_downstream_services() { int port1 = RandomPortFinder.GetRandomPort(); int port2 = RandomPortFinder.GetRandomPort(); var configuration = new FileConfiguration { ReRoutes = new List <FileReRoute> { new FileReRoute { DownstreamPathTemplate = "/api/values", DownstreamScheme = "http", DownstreamHostAndPorts = new List <FileHostAndPort> { new FileHostAndPort { Host = "localhost", Port = port1, } }, UpstreamPathTemplate = "/api001/values", UpstreamHttpMethod = new List <string> { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { UseTracing = true } }, new FileReRoute { DownstreamPathTemplate = "/api/values", DownstreamScheme = "http", DownstreamHostAndPorts = new List <FileHostAndPort> { new FileHostAndPort { Host = "localhost", Port = port2, } }, UpstreamPathTemplate = "/api002/values", UpstreamHttpMethod = new List <string> { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { UseTracing = true } } } }; var butterflyPort = RandomPortFinder.GetRandomPort(); var butterflyUrl = $"http://localhost:{butterflyPort}"; this.Given(x => GivenFakeButterfly(butterflyUrl)) .And(x => GivenServiceOneIsRunning($"http://localhost:{port1}", "/api/values", 200, "Hello from Laura", butterflyUrl)) .And(x => GivenServiceTwoIsRunning($"http://localhost:{port2}", "/api/values", 200, "Hello from Tom", butterflyUrl)) .And(x => _steps.GivenThereIsAConfiguration(configuration)) .And(x => _steps.GivenOcelotIsRunningUsingButterfly(butterflyUrl)) .When(x => _steps.WhenIGetUrlOnTheApiGateway("/api001/values")) .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura")) .When(x => _steps.WhenIGetUrlOnTheApiGateway("/api002/values")) .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Tom")) .BDDfy(); var commandOnAllStateMachines = Wait.WaitFor(10000).Until(() => _butterflyCalled >= 4); _output.WriteLine($"_butterflyCalled is {_butterflyCalled}"); commandOnAllStateMachines.ShouldBeTrue(); }
public void should_forward_tracing_information_from_ocelot_and_downstream_services() { var configuration = new FileConfiguration { ReRoutes = new List <FileReRoute> { new FileReRoute { DownstreamPathTemplate = "/api/values", DownstreamScheme = "http", DownstreamHostAndPorts = new List <FileHostAndPort> { new FileHostAndPort { Host = "localhost", Port = 51887, } }, UpstreamPathTemplate = "/api001/values", UpstreamHttpMethod = new List <string> { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { UseTracing = true }, QoSOptions = new FileQoSOptions { ExceptionsAllowedBeforeBreaking = 3, DurationOfBreak = 10, TimeoutValue = 5000 } }, new FileReRoute { DownstreamPathTemplate = "/api/values", DownstreamScheme = "http", DownstreamHostAndPorts = new List <FileHostAndPort> { new FileHostAndPort { Host = "localhost", Port = 51388, } }, UpstreamPathTemplate = "/api002/values", UpstreamHttpMethod = new List <string> { "Get" }, HttpHandlerOptions = new FileHttpHandlerOptions { UseTracing = true }, QoSOptions = new FileQoSOptions { ExceptionsAllowedBeforeBreaking = 3, DurationOfBreak = 10, TimeoutValue = 5000 } } } }; var butterflyUrl = "http://localhost:9618"; this.Given(x => GivenFakeButterfly(butterflyUrl)) .And(x => GivenServiceOneIsRunning("http://localhost:51887", "/api/values", 200, "Hello from Laura", butterflyUrl)) .And(x => GivenServiceTwoIsRunning("http://localhost:51388", "/api/values", 200, "Hello from Tom", butterflyUrl)) .And(x => _steps.GivenThereIsAConfiguration(configuration)) .And(x => _steps.GivenOcelotIsRunningUsingButterfly(butterflyUrl)) .When(x => _steps.WhenIGetUrlOnTheApiGateway("/api001/values")) .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura")) .When(x => _steps.WhenIGetUrlOnTheApiGateway("/api002/values")) .Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) .And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Tom")) .BDDfy(); var commandOnAllStateMachines = WaitFor(10000).Until(() => _butterflyCalled == 4); commandOnAllStateMachines.ShouldBeTrue(); }