mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-08-04 19:12:25 +08:00
Activate ChangeToken when Ocelot's configuration changes #1037
* Add configuration change token (#1036) * Add IOptionsMonitor<IInternalConfiguration> * Activate change token from *ConfigurationRepository instead of FileAndInternalConfigurationSetter; add acceptance & integration tests * Update documentation * Use IWebHostEnvironment as IHostingEnvironment deprecated Co-authored-by: Chris Swinchatt <chrisswinchatt@gmail.com>
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Ocelot.Configuration.File;
|
||||
using System;
|
||||
using Ocelot.Configuration.ChangeTracking;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
@ -54,6 +55,33 @@ namespace Ocelot.AcceptanceTests
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_trigger_change_token_on_change()
|
||||
{
|
||||
this.Given(x => _steps.GivenThereIsAConfiguration(_initialConfig))
|
||||
.And(x => _steps.GivenOcelotIsRunningReloadingConfig(true))
|
||||
.And(x => _steps.GivenIHaveAChangeToken())
|
||||
.And(x => _steps.GivenThereIsAConfiguration(_anotherConfig))
|
||||
.And(x => _steps.GivenIWait(MillisecondsToWaitForChangeToken))
|
||||
.Then(x => _steps.TheChangeTokenShouldBeActive(true))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_not_trigger_change_token_with_no_change()
|
||||
{
|
||||
this.Given(x => _steps.GivenThereIsAConfiguration(_initialConfig))
|
||||
.And(x => _steps.GivenOcelotIsRunningReloadingConfig(false))
|
||||
.And(x => _steps.GivenIHaveAChangeToken())
|
||||
.And(x => _steps.GivenIWait(MillisecondsToWaitForChangeToken)) // Wait for prior activation to expire.
|
||||
.And(x => _steps.GivenThereIsAConfiguration(_anotherConfig))
|
||||
.And(x => _steps.GivenIWait(MillisecondsToWaitForChangeToken))
|
||||
.Then(x => _steps.TheChangeTokenShouldBeActive(false))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private const int MillisecondsToWaitForChangeToken = (int) (OcelotConfigurationChangeToken.PollingIntervalSeconds*1000) - 100;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_steps.Dispose();
|
||||
|
Reference in New Issue
Block a user