Skip to content

Commit

Permalink
Trying yet another strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ggnaegi committed Sep 24, 2023
1 parent 9fac778 commit 1c97c39
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 1 addition & 2 deletions test/Ocelot.AcceptanceTests/ConfigurationReloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
26 changes: 24 additions & 2 deletions test/Ocelot.AcceptanceTests/Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,37 @@ public class Steps : IDisposable
public async Task ThenConfigShouldBe(FileConfiguration fileConfig)
{
var internalConfigCreator = _ocelotServer.Host.Services.GetService<IInternalConfigurationCreator>();

var internalConfigRepo = _ocelotServer.Host.Services.GetService<IInternalConfigurationRepository>();
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<IInternalConfigurationCreator>();
var internalConfigRepo = _ocelotServer.Host.Services.GetService<IInternalConfigurationRepository>();
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();
Expand Down

0 comments on commit 1c97c39

Please sign in to comment.