diff --git a/test/Ocelot.AcceptanceTests/ConfigurationReloadTests.cs b/test/Ocelot.AcceptanceTests/ConfigurationReloadTests.cs index a9656ce68..faf528dad 100644 --- a/test/Ocelot.AcceptanceTests/ConfigurationReloadTests.cs +++ b/test/Ocelot.AcceptanceTests/ConfigurationReloadTests.cs @@ -42,8 +42,7 @@ public void should_reload_config_on_change() this.Given(x => _steps.GivenThereIsAConfiguration(_initialConfig)) .And(x => _steps.GivenOcelotIsRunningReloadingConfig(true)) .And(x => _steps.GivenThereIsAConfiguration(_anotherConfig)) - .And(x => _steps.GivenIWait(7500)) - .And(x => _steps.ThenConfigShouldBe(_anotherConfig)) + .And(x => _steps.ThenConfigShouldBeWithTimeout(_anotherConfig, 10000)) .BDDfy(); } diff --git a/test/Ocelot.AcceptanceTests/Steps.cs b/test/Ocelot.AcceptanceTests/Steps.cs index e585b1c8b..1499995a9 100644 --- a/test/Ocelot.AcceptanceTests/Steps.cs +++ b/test/Ocelot.AcceptanceTests/Steps.cs @@ -65,15 +65,37 @@ public class Steps : IDisposable public async Task ThenConfigShouldBe(FileConfiguration fileConfig) { var internalConfigCreator = _ocelotServer.Host.Services.GetService(); - var internalConfigRepo = _ocelotServer.Host.Services.GetService(); - var internalConfig = internalConfigRepo.Get(); + var internalConfig = internalConfigRepo.Get(); var config = await internalConfigCreator.Create(fileConfig); internalConfig.Data.RequestId.ShouldBe(config.Data.RequestId); } + public async Task ThenConfigShouldBeWithTimeout(FileConfiguration fileConfig, int timeoutMs) + { + var totalMs = 0; + var result = false; + + while (!result && totalMs < timeoutMs) + { + result = await Wait.WaitFor(1000).Until(async () => + { + var internalConfigCreator = _ocelotServer.Host.Services.GetService(); + var internalConfigRepo = _ocelotServer.Host.Services.GetService(); + + var internalConfig = internalConfigRepo.Get(); + var config = await internalConfigCreator.Create(fileConfig); + + return internalConfig.Data.RequestId == config.Data.RequestId; + }); + totalMs += 1000; + } + + result.ShouldBe(true); + } + public async Task StartFakeOcelotWithWebSockets() { _ocelotBuilder = new WebHostBuilder();