Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions OptimizelySDK.Tests/ConfigTest/PollingProjectConfigManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ public void TestTimedoutOnlyIfSchedulerStarted()
configManager.Dispose();
}

[Test]
public void TestWarnLogIfPollingTimeIsLessThanThirty()
{
var below30Seconds = TimeSpan.FromSeconds(29);
_ = new TestPollingProjectConfigManager(below30Seconds,
TimeSpan.FromSeconds(10), true, LoggerMock.Object, new int[] { });
LoggerMock.Verify(l => l.Log(LogLevel.WARN,
"Polling intervals below 30 seconds are not recommended."), Times.Once);
}
[Test]
public void TestWarnLogNotTriggeredIfPollingTimeIsGreaterThanThirty()
{
var above30Seconds = TimeSpan.FromMinutes(1);
_ = new TestPollingProjectConfigManager(above30Seconds,
TimeSpan.FromMilliseconds(10), true, LoggerMock.Object, new int[] { });
LoggerMock.Verify(l => l.Log(LogLevel.WARN,
"Polling intervals below 30 seconds are not recommended."), Times.Never);
}

[Test]
public void TestDontTimedoutIfSchedulerNotStarted()
{
Expand Down
4 changes: 4 additions & 0 deletions OptimizelySDK/Config/PollingProjectConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public PollingProjectConfigManager(TimeSpan period, TimeSpan blockingTimeout,
Logger = logger;
ErrorHandler = errorHandler;
BlockingTimeout = blockingTimeout;
if (period.TotalSeconds < 30)
{
Logger?.Log(LogLevel.WARN, "Polling intervals below 30 seconds are not recommended.");
}
PollingInterval = period;
AutoUpdate = autoUpdate;

Expand Down