fix(purge): short first tick on all three purge timers so daily-recycled nodes still purge

This commit is contained in:
Joseph Doherty
2026-07-09 09:26:42 -04:00
parent 7cd62933a6
commit b58d810dbe
5 changed files with 89 additions and 5 deletions
@@ -0,0 +1,40 @@
using ZB.MOM.WW.ScadaBridge.Commons.Types;
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Types;
/// <summary>
/// Covers the shared purge-timer initial-delay rule (arch-review 04, S9): the
/// three central purge singletons must NOT wait a full (up to 24 h) interval
/// before their first tick, or a node recycled daily would never purge. The
/// initial delay is min(interval, 5 min).
/// </summary>
public class PurgeTimerScheduleTests
{
[Fact]
public void InitialDelay_LongInterval_IsCappedAtShortFirstTick()
{
// A daily (24 h) cadence must still fire its first purge within 5 minutes.
Assert.Equal(PurgeTimerSchedule.ShortFirstTick, PurgeTimerSchedule.InitialDelay(TimeSpan.FromHours(24)));
}
[Fact]
public void InitialDelay_IntervalShorterThanShortFirstTick_IsUnchanged()
{
// A millisecond test cadence must be preserved verbatim (min picks the interval),
// so the existing fast-tick actor suites keep their sub-second timing.
var fast = TimeSpan.FromMilliseconds(100);
Assert.Equal(fast, PurgeTimerSchedule.InitialDelay(fast));
}
[Fact]
public void InitialDelay_IntervalEqualToShortFirstTick_IsThatValue()
{
Assert.Equal(PurgeTimerSchedule.ShortFirstTick, PurgeTimerSchedule.InitialDelay(PurgeTimerSchedule.ShortFirstTick));
}
[Fact]
public void ShortFirstTick_IsFiveMinutes()
{
Assert.Equal(TimeSpan.FromMinutes(5), PurgeTimerSchedule.ShortFirstTick);
}
}