From 05b2d27e88b7f56edb2a1141acc3dd3e8c59be95 Mon Sep 17 00:00:00 2001 From: support Date: Wed, 18 Nov 2026 07:52:52 +0100 Subject: [PATCH] Give the failing-renewals lease test room for late timers The run stops one renewal interval before its lease runs out. With a 200 ms interval, four late Task.Delay calls on a busy CI runner were enough to push the cancellation past the lease, and the test failed. A 500 ms interval with a 2 s lease leaves the same check 500 ms of slack. --- .../Infrastructure/BackgroundServiceTaskTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Tests/Grand.Web.Common.Tests/Infrastructure/BackgroundServiceTaskTests.cs b/src/Tests/Grand.Web.Common.Tests/Infrastructure/BackgroundServiceTaskTests.cs index c051b279f..4b5bef7d5 100644 --- a/src/Tests/Grand.Web.Common.Tests/Infrastructure/BackgroundServiceTaskTests.cs +++ b/src/Tests/Grand.Web.Common.Tests/Infrastructure/BackgroundServiceTaskTests.cs @@ -336,8 +336,10 @@ public async Task ExecuteAsync_RenewalsKeepFailing_CancelsTheRunBeforeTheLeaseRu } }); - var service = new BackgroundServiceTask(TaskName, _serviceProvider, TimeSpan.FromMilliseconds(200), - TimeSpan.FromSeconds(1)); + //the run stops one renewal interval before the lease runs out; the delays between renewals may each come + //late on a busy machine, so the interval leaves room for that + var service = new BackgroundServiceTask(TaskName, _serviceProvider, TimeSpan.FromMilliseconds(500), + TimeSpan.FromSeconds(2)); using var cts = new CancellationTokenSource(); await service.StartAsync(cts.Token);