Ejemplo n.º 1
0
        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
                        }
                    },
                    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
                        }
                    }
                }
            };

            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 = Wait.WaitFor(10000).Until(() => _butterflyCalled >= 4);

            _output.WriteLine($"_butterflyCalled is {_butterflyCalled}");

            commandOnAllStateMachines.ShouldBeTrue();
        }