From bdcd4e42aeafbc82b8d95ad9ffcc11f4e28e4bcc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 22:03:31 +0000 Subject: [PATCH] test(server): the busy-log test writes a line a millisecond, never in a tight loop Engine code of every test server in the process logs through the last server started (Log.SetSink is process-wide), so the busy-log test's file lock is shared with the classes running alongside: a loop that re-took it at once kept a job engine of JobApiTests waiting to log a failure, and its job "running" past the 15 s deadline (once in 40 loaded runs). The test now fills the log with a few megabytes up front, so sending it takes a while, and adds a line about every millisecond during the downloads; it still fails every run against the old endpoint. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- tests/Titano.Server.Tests/Api/AdminTests.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/Titano.Server.Tests/Api/AdminTests.cs b/tests/Titano.Server.Tests/Api/AdminTests.cs index 3de0b7fe..4553a203 100644 --- a/tests/Titano.Server.Tests/Api/AdminTests.cs +++ b/tests/Titano.Server.Tests/Api/AdminTests.cs @@ -76,13 +76,21 @@ public sealed class AdminTests(TestContext context) var admin = await server.AdminAsync(); using var files = await admin.GetAsync("/api/v1/logs/files"); var name = (await files.ReadAsync(ProtocolJson.Default.ListLogFileDto)).First().Name; - // Jobs, uploads and sign-ins keep writing to the file an administrator downloads. Only to the file: a flood on - // the console would hold up the loggers of the tests running alongside. + // Jobs, uploads and sign-ins keep writing to the file an administrator downloads: a log of a few megabytes takes + // a while to send, and a line lands about every millisecond meanwhile. Only to the file and never in a tight loop: + // engine code of every test server in this process logs through the last one started, so this server's console + // and file lock are shared with the tests running alongside. var logger = server.Services.GetServices().OfType().Single().CreateLogger("Titano.Server.Tests"); + var block = new string('x', 64 * 1024); + for (var i = 0; i < 32; i++) logger.LogInformation("{Block}", block); using var stop = new CancellationTokenSource(); var logging = Task.Factory.StartNew(() => { - while (!stop.IsCancellationRequested) logger.LogInformation("Busy"); + while (!stop.IsCancellationRequested) + { + logger.LogInformation("Busy"); + Thread.Sleep(1); + } }, TaskCreationOptions.LongRunning); try {