Example #1
0
        private void ThenTheTracerIsCalled(FakeTracer fakeTracer)
        {
            var commandOnAllStateMachines = Wait.WaitFor(10000).Until(() => fakeTracer.BuildSpanCalled >= 2);

            _output.WriteLine($"fakeTracer.BuildSpanCalled is {fakeTracer.BuildSpanCalled}");

            commandOnAllStateMachines.ShouldBeTrue();
        }
Example #2
0
        public void WhenIGetUrlOnTheApiGatewayWaitingForTheResponseToBeOk(string url)
        {
            var result = Wait.WaitFor(2000).Until(() => {
                try
                {
                    _response = _ocelotClient.GetAsync(url).Result;
                    _response.EnsureSuccessStatusCode();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            });

            result.ShouldBeTrue();
        }
        private void ThenTheConfigIsUpdatedInOcelot()
        {
            var result = Wait.WaitFor(20000).Until(() => {
                try
                {
                    _steps.WhenIGetUrlOnTheApiGateway("/cs/status/awesome");
                    _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK);
                    _steps.ThenTheResponseBodyShouldBe("Hello from Laura");
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            });

            result.ShouldBeTrue();
        }
Example #4
0
        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();
        }