From 44e5b9da9e2502e78d3fcdca173aad46fefad224 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Tue, 27 Oct 2026 15:50:25 +0100 Subject: [PATCH] test(core): a lease test checks the renewal, not a millisecond race The v0.1.0-rc.5 release build failed on the shared runner when the last renewal timer ran 75 ms late: the test now checks that the expiry moved on. Co-Authored-By: Claude Opus 5.5 --- tests/Chronos.Core.Tests/Archiving/LeaseFileTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Chronos.Core.Tests/Archiving/LeaseFileTests.cs b/tests/Chronos.Core.Tests/Archiving/LeaseFileTests.cs index 9280b5e5..49ba2025 100644 --- a/tests/Chronos.Core.Tests/Archiving/LeaseFileTests.cs +++ b/tests/Chronos.Core.Tests/Archiving/LeaseFileTests.cs @@ -70,9 +70,12 @@ public sealed class LeaseFileTests(TestContext context) var duration = TimeSpan.FromSeconds(TestTiming.Budget(0.3)); using var lease = LeaseFile.TryAcquire(locks, "seq-1", "server", duration); Assert.NotNull(lease); + var first = LeaseFile.Read(lease.Path)!.Expires; await Task.Delay(duration * 3); Assert.True(lease.IsHeld); - Assert.Greater((LeaseFile.Read(lease.Path)!.Expires - DateTimeOffset.UtcNow).TotalMilliseconds, 0); + // Renewed: the expiry moved on. Whether it is still ahead of the clock at this instant depends on when the last + // timer ran, which a busy runner can delay by a few milliseconds past it. + Assert.Greater((LeaseFile.Read(lease.Path)!.Expires - first).TotalMilliseconds, duration.TotalMilliseconds); Assert.Null(LeaseFile.TryAcquire(locks, "seq-1", "client", duration)); }