From 979357b2ea19e04f85cbc8e532f2882fde0f0e17 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Thu, 13 Aug 2026 20:29:51 +0000 Subject: [PATCH] fix(tests): stop SessionLogActor diagnostic test racing the FlushTick MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dispatcher_writes_audit_and_diagnostic_to_same_session_log sent the buffered diagnostic AFTER the durable audit line, so the diagnostic only became visible when the actor's 1s wall-clock FlushTick fired. On loaded Windows CI runners the tick can land past the 3s AwaitAssertAsync budget, failing the test even though the write was correct (seen on run 31715544081, job 94499226187). Send the buffered diagnostic first; the durable audit write drains it synchronously via WriteDurable — the documented natural flush point. The test no longer depends on the wall-clock timer (verified: passes in ~0.5s, previously ~1s gated on the tick). --- src/Netclaw.Actors.Tests/Sessions/SessionLogActorTests.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Netclaw.Actors.Tests/Sessions/SessionLogActorTests.cs b/src/Netclaw.Actors.Tests/Sessions/SessionLogActorTests.cs index c448e3124..69c66e429 100644 --- a/src/Netclaw.Actors.Tests/Sessions/SessionLogActorTests.cs +++ b/src/Netclaw.Actors.Tests/Sessions/SessionLogActorTests.cs @@ -201,9 +201,13 @@ public async Task Dispatcher_writes_audit_and_diagnostic_to_same_session_log() { var dispatcher = SpawnDispatcher(Sys, basePath, timeProvider); - dispatcher.Tell(new TextOutput("audit-line") { SessionId = sessionId }, ActorRefs.NoSender); + // Buffered diagnostic first; the durable audit write below drains + // it synchronously (SessionLogActor.WriteDurable) — no dependence + // on the 1s FlushTick wall-clock timer, which is what made this + // test flaky on loaded Windows CI runners. timeProvider.Advance(TimeSpan.FromMilliseconds(1)); dispatcher.Tell(new SessionLogDiagnostic(sessionId, "[2026-05-07T13:30:00.001+00:00] Diagnostic: provider sent request"), ActorRefs.NoSender); + dispatcher.Tell(new TextOutput("audit-line") { SessionId = sessionId }, ActorRefs.NoSender); await AwaitAssertAsync(async () => {