test(historian): justify/tighten the shutdown watch window; single read of RemoveCallCount per poll
This commit is contained in:
+13
-3
@@ -609,12 +609,22 @@ public sealed class ContinuousHistorizationRecorderTests : TestKit
|
|||||||
// the queued count moving off 2. Either fires the moment the unfixed recorder books the failure and
|
// the queued count moving off 2. Either fires the moment the unfixed recorder books the failure and
|
||||||
// truncates, so a regression fails in milliseconds rather than after a fixed sleep; only the passing
|
// truncates, so a regression fails in milliseconds rather than after a fixed sleep; only the passing
|
||||||
// case pays the full window.
|
// case pays the full window.
|
||||||
|
//
|
||||||
|
// 1s is the window, and it is already generous headroom rather than a guess: everything it waits on
|
||||||
|
// is prompt on this fixture — the cancellation of the writer's `Task.Delay(Timeout.Infinite, ct)` is
|
||||||
|
// essentially synchronous (and `writer.Cancelled` above has already fired), the fold that would
|
||||||
|
// truncate runs immediately behind it, and the recorder's own cadence here is a 20ms drain interval
|
||||||
|
// with a 20-50ms backoff. The unfixed recorder trips this in ~150ms including startup, so the
|
||||||
|
// remaining ~6x is CI-load slack, not mechanism.
|
||||||
var watch = Stopwatch.StartNew();
|
var watch = Stopwatch.StartNew();
|
||||||
while (watch.Elapsed < TimeSpan.FromSeconds(2))
|
while (watch.Elapsed < TimeSpan.FromSeconds(1))
|
||||||
{
|
{
|
||||||
|
// Read once per iteration: the condition and its failure message must report the SAME
|
||||||
|
// observation, or a red run names a count that is not the one that tripped.
|
||||||
|
int removeCalls = outbox.RemoveCallCount;
|
||||||
Assert.True(
|
Assert.True(
|
||||||
outbox.RemoveCallCount == 0,
|
removeCalls == 0,
|
||||||
$"the cancelled pass acked: RemoveAsync ran {outbox.RemoveCallCount}x, truncating the queue");
|
$"the cancelled pass acked: RemoveAsync ran {removeCalls}x, truncating the queue");
|
||||||
int queued = await outbox.CountAsync(default);
|
int queued = await outbox.CountAsync(default);
|
||||||
Assert.True(queued == 2, $"the cancelled pass changed the queue depth: expected 2, saw {queued}");
|
Assert.True(queued == 2, $"the cancelled pass changed the queue depth: expected 2, saw {queued}");
|
||||||
await Task.Delay(25);
|
await Task.Delay(25);
|
||||||
|
|||||||
Reference in New Issue
Block a user