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 <noreply@anthropic.com>
This commit is contained in:
1 parent
950524929c
commit
44e5b9da9e
1 file changed
+4
-1
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user