test(worker): poll for terminal state in the registration-race tests instead of fixed delays
This commit is contained in:
@@ -671,7 +671,9 @@ public sealed class QueueServiceTests : IDisposable
|
|||||||
|
|
||||||
// The picker's retry must have registered the CTS actually driving this run.
|
// The picker's retry must have registered the CTS actually driving this run.
|
||||||
Assert.True(service.CancelTask(task.Id));
|
Assert.True(service.CancelTask(task.Id));
|
||||||
await Task.Delay(200);
|
var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(10);
|
||||||
|
while (!cancelled && DateTime.UtcNow < deadline)
|
||||||
|
await Task.Delay(25);
|
||||||
Assert.True(cancelled);
|
Assert.True(cancelled);
|
||||||
|
|
||||||
cts.Cancel();
|
cts.Cancel();
|
||||||
@@ -696,13 +698,19 @@ public sealed class QueueServiceTests : IDisposable
|
|||||||
await service.StartAsync(cts.Token);
|
await service.StartAsync(cts.Token);
|
||||||
_waker.Wake();
|
_waker.Wake();
|
||||||
|
|
||||||
// Max retry window is 10 * 20ms; give it comfortable headroom.
|
// The retry window is 10 * 20ms of Task.Delay, but under full-suite load those delays
|
||||||
await Task.Delay(600);
|
// stretch — poll for the terminal state instead of guessing a fixed headroom.
|
||||||
|
TaskEntity? reloaded = null;
|
||||||
|
var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(10);
|
||||||
|
while (DateTime.UtcNow < deadline)
|
||||||
|
{
|
||||||
|
reloaded = await _taskRepo.GetByIdAsync(task.Id);
|
||||||
|
if (reloaded!.Status == TaskStatus.Failed) break;
|
||||||
|
await Task.Delay(25);
|
||||||
|
}
|
||||||
cts.Cancel();
|
cts.Cancel();
|
||||||
|
|
||||||
Assert.Equal(0, fake.CallCount);
|
Assert.Equal(0, fake.CallCount);
|
||||||
|
|
||||||
var reloaded = await _taskRepo.GetByIdAsync(task.Id);
|
|
||||||
Assert.Equal(TaskStatus.Failed, reloaded!.Status);
|
Assert.Equal(TaskStatus.Failed, reloaded!.Status);
|
||||||
|
|
||||||
// The still-registered "other" run must be untouched.
|
// The still-registered "other" run must be untouched.
|
||||||
|
|||||||
Reference in New Issue
Block a user