From f4c529c8533ed7574cab887de23a1f9d77a53129 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 21:04:55 +0000 Subject: [PATCH 1/6] test(sync): wait for the comparison an event starts, not for its first write ATimedOutComparisonIsRecordedAndLiveUpdatesGoOn polled until the server's settings reached the local copy and then asserted that the link's error was cleared. The engine writes the local copy first and stores the link (error cleared, versions agreed) afterwards, so a poll landing between the two writes saw the old error: 1 failure in 60 runs idle, 11 in 60 under CPU load. The agent tests now wait for SyncService.Changed, which the engine raises once a comparison stored every link and state (the moment the Server screen reloads), and assert on that settled state. The same fix applies to the proxy refresh test (the cache is complete before the link and the job: it waits for the job, whose row showed Transferring until then) and the retry test (the agent stores the snapshot before it clears the last error and raises Changed). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- .../Titano.Data.Tests/Sync/SyncAgentTests.cs | 91 +++++++++++++++---- 1 file changed, 75 insertions(+), 16 deletions(-) diff --git a/tests/Titano.Data.Tests/Sync/SyncAgentTests.cs b/tests/Titano.Data.Tests/Sync/SyncAgentTests.cs index 28853332..cfdc577a 100644 --- a/tests/Titano.Data.Tests/Sync/SyncAgentTests.cs +++ b/tests/Titano.Data.Tests/Sync/SyncAgentTests.cs @@ -9,6 +9,9 @@ namespace Titano.Data.Tests.Sync; [Category("sync")] public sealed class SyncAgentTests(TestContext context) { + /// How long any wait may take on a loaded runner; every wait ends as soon as what it waits for happened. + private static readonly TimeSpan Deadline = TimeSpan.FromSeconds(30); + /// Full comparisons only at start, so anything later comes from events or explicit requests. private static readonly SyncAgentOptions EventsOnly = new() { @@ -31,14 +34,20 @@ public sealed class SyncAgentTests(TestContext context) await WaitAsync(() => agent.Snapshot is not null, "first comparison"); var first = agent.Snapshot!; - f.Remote.EditSettings(remote.Id, SyncFixture.Window33); - f.Remote.Publish(new SequenceChangedEvent(remote.Id, "settings", remote.FramesVersion, remote.SettingsVersion)); - await WaitAsync(async () => SyncRules.SameSettings(SyncFixture.Window33, (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.SettingsJson), + await ComparedAfterAsync(f, () => + { + f.Remote.EditSettings(remote.Id, SyncFixture.Window33); + f.Remote.Publish(new SequenceChangedEvent(remote.Id, "settings", remote.FramesVersion, remote.SettingsVersion)); + }, "the comparison of the server's edit"); + Assert.True(SyncRules.SameSettings(SyncFixture.Window33, (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.SettingsJson), "the server's edit reached this PC"); - var created = f.Remote.Add("New on the server", f.NewPhotos(1)); - f.Remote.Publish(new SequenceChangedEvent(created.Id, "created", 1, 1)); - await WaitAsync(async () => (await f.Sync.ListAsync(f.Server, f.Ct)).Any(e => e.Title == "New on the server"), "a sequence created on the server"); + await ComparedAfterAsync(f, () => + { + var created = f.Remote.Add("New on the server", f.NewPhotos(1)); + f.Remote.Publish(new SequenceChangedEvent(created.Id, "created", 1, 1)); + }, "the comparison of a sequence created on the server"); + Assert.Contains(await f.Sync.ListAsync(f.Server, f.Ct), e => e.Title == "New on the server"); Assert.Same(first, agent.Snapshot); } @@ -49,11 +58,17 @@ public sealed class SyncAgentTests(TestContext context) f.Remote.Add("Harbour", f.NewPhotos(1)); f.Remote.FailingListings = 3; var changes = 0; + var compared = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); await using var agent = new SyncAgent(f.Sync, f.Remote, () => new SyncPolicy(), null, EventsOnly); - agent.Changed += () => Interlocked.Increment(ref changes); + // The agent stores the snapshot, then clears the last error, then raises Changed: only Changed sees both. + agent.Changed += () => + { + Interlocked.Increment(ref changes); + if (agent.Snapshot is not null) compared.TrySetResult(); + }; agent.Start(); - await WaitAsync(() => agent.Snapshot is not null, "a comparison after the failures"); + await SignalAsync(compared.Task, "a comparison after the failures"); Assert.Null(agent.LastError); Assert.Equal(0, f.Remote.FailingListings); Assert.GreaterOrEqual(changes, 4); @@ -72,13 +87,19 @@ public sealed class SyncAgentTests(TestContext context) agent.Start(); await WaitAsync(() => agent.Snapshot is not null, "first comparison"); - f.Remote.TimeoutOnce = remote.Id; - f.Remote.Publish(new SequenceChangedEvent(remote.Id, "settings", remote.FramesVersion, remote.SettingsVersion)); - await WaitAsync(async () => (await f.EntryAsync("Harbour")).Link!.Error is not null, "the timeout recorded on the sequence"); + await ComparedAfterAsync(f, () => + { + f.Remote.TimeoutOnce = remote.Id; + f.Remote.Publish(new SequenceChangedEvent(remote.Id, "settings", remote.FramesVersion, remote.SettingsVersion)); + }, "the comparison that timed out"); + Assert.NotNull((await f.EntryAsync("Harbour")).Link!.Error); - f.Remote.EditSettings(remote.Id, SyncFixture.Window33); - f.Remote.Publish(new SequenceChangedEvent(remote.Id, "settings", remote.FramesVersion, remote.SettingsVersion)); - await WaitAsync(async () => SyncRules.SameSettings(SyncFixture.Window33, (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.SettingsJson), + await ComparedAfterAsync(f, () => + { + f.Remote.EditSettings(remote.Id, SyncFixture.Window33); + f.Remote.Publish(new SequenceChangedEvent(remote.Id, "settings", remote.FramesVersion, remote.SettingsVersion)); + }, "the comparison of a later event"); + Assert.True(SyncRules.SameSettings(SyncFixture.Window33, (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!.SettingsJson), "a later event still reaches this PC"); Assert.Null((await f.EntryAsync("Harbour")).Link!.Error); } @@ -105,7 +126,10 @@ public sealed class SyncAgentTests(TestContext context) keep = true; await agent.RefreshAsync(f.Ct); - await WaitAsync(() => f.Sync.OpenRemote(f.Server, opened.Id) is { CachedCount: 3 }, "the stale cache brought up to date"); + // The download writes the cache, then the link, and only then ends: until it ends its row shows a transfer. + var refresh = Assert.Contains(await DownloadsAsync(f), j => j.Id != first.Id); + await f.Archive.WaitForAsync(refresh.Id, JobState.Done); + Assert.Equal(3, Assert.NotNull(f.Sync.OpenRemote(f.Server, opened.Id)).CachedCount, "the stale cache brought up to date"); Assert.Null(f.Sync.OpenRemote(f.Server, never.Id)); var entries = await f.Sync.ListAsync(f.Server, f.Ct); Assert.Equal(SyncStatus.ProxiesOnly, entries.Single(e => e.Title == "Construction cam").Status); @@ -138,11 +162,46 @@ public sealed class SyncAgentTests(TestContext context) private static async Task> DownloadsAsync(SyncFixture f) => (await f.Db.Jobs.ListAsync(null, JobKind.Download, 100, null, f.Ct)).Items; + /// + /// Runs and returns once the comparison it starts has finished. The engine raises + /// after a comparison stored every link and state, the moment the Server screen + /// reloads; a poll could instead see the local copy updated before the link that goes with it is stored. No other + /// comparison may be running. + /// + private async Task ComparedAfterAsync(SyncFixture f, Action cause, string what) + { + // Continuations run on the pool, not inside the agent loop that raises Changed and that the test later stops. + var compared = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + Action onChanged = _ => compared.TrySetResult(); + f.Sync.Changed += onChanged; + try + { + cause(); + await SignalAsync(compared.Task, what); + } + finally + { + f.Sync.Changed -= onChanged; + } + } + + private async Task SignalAsync(Task signal, string what) + { + try + { + await signal.WaitAsync(Deadline, context.Cancellation); + } + catch (TimeoutException) + { + Assert.Fail("Timed out waiting for " + what); + } + } + private async Task WaitAsync(Func condition, string what) => await WaitAsync(() => Task.FromResult(condition()), what); private async Task WaitAsync(Func> condition, string what) { - var until = DateTime.UtcNow.AddSeconds(30); + var until = DateTime.UtcNow + Deadline; while (!await condition()) { if (DateTime.UtcNow > until) Assert.Fail("Timed out waiting for " + what); From 9566818fd60e92fbd5abae86ec4650bef41ef693 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 21:11:27 +0000 Subject: [PATCH 2/6] test(sync): the server event test waits for the comparison the edit starts ServerEventsUpdateThisPcWithoutWaitingForTheNextComparison polled until the server's settings reached the local copy, then expected the row in sync; the link that records the agreement is stored after the local copy, so the row could still read LocalAhead (1 failure in 15 loaded runs). It now waits for SyncService.Changed, raised once the comparison stored every link and state. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- .../Sync/SyncServerTests.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/Titano.Server.Tests/Sync/SyncServerTests.cs b/tests/Titano.Server.Tests/Sync/SyncServerTests.cs index c7d1c00b..daea9b86 100644 --- a/tests/Titano.Server.Tests/Sync/SyncServerTests.cs +++ b/tests/Titano.Server.Tests/Sync/SyncServerTests.cs @@ -22,6 +22,9 @@ public sealed class SyncServerTests(TestContext context) private const string Window41 = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":41}}}"""; private const string Window33 = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":33}}}"""; + /// How long any wait may take on a loaded runner; every wait ends as soon as what it waits for happened. + private static readonly TimeSpan Deadline = TimeSpan.FromSeconds(60); + [Test] public async Task ASequenceUploadedFromOnePcDownloadsIdenticallyOnAnother() { @@ -147,12 +150,16 @@ public sealed class SyncServerTests(TestContext context) var hub = server.Services.GetRequiredService(); await UntilAsync(() => Task.FromResult(agent.Snapshot is not null && hub.SubscriberCount > 0), "the agent's first comparison and event socket"); - // Someone edits the project on the server (web or another PC). + // Someone edits the project on the server (web or another PC). The comparison its event starts writes the + // settings on this PC before the link that records the agreement: wait for the comparison, not for the settings. + var compared = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + studio.Sync.Changed += _ => compared.TrySetResult(); using (var patch = await http.PatchAsJsonAsync($"/api/v1/sequences/{remoteId}", new UpdateSequenceRequest(null, null, null, null, Window33, null), ProtocolJson.Default.UpdateSequenceRequest)) await patch.ExpectAsync(HttpStatusCode.OK); - await UntilAsync(async () => ProjectSettings.FromJson((await studio.Db.Sequences.GetAsync(local.Id))!.SettingsJson ?? "{}").Exposure.DeflickerWindow.Manual == 33, + await SignalAsync(compared.Task, "the comparison of the edit"); + Assert.Equal(33, ProjectSettings.FromJson((await studio.Db.Sequences.GetAsync(local.Id))!.SettingsJson ?? "{}").Exposure.DeflickerWindow.Manual, "the edit reached this PC"); Assert.Equal(SyncStatus.InSync, (await studio.EntryAsync("Harbour sunset")).Status); } @@ -244,11 +251,23 @@ public sealed class SyncServerTests(TestContext context) private async Task UntilAsync(Func> condition, string what) { - var until = DateTime.UtcNow.AddSeconds(60); + var until = DateTime.UtcNow + Deadline; while (!await condition()) { if (DateTime.UtcNow > until) Assert.Fail("Timed out waiting for " + what); await Task.Delay(50, context.Cancellation); } } + + private async Task SignalAsync(Task signal, string what) + { + try + { + await signal.WaitAsync(Deadline, context.Cancellation); + } + catch (TimeoutException) + { + Assert.Fail("Timed out waiting for " + what); + } + } } From 9c00977dab2849857f24571a6e76939662d1034a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 21:11:27 +0000 Subject: [PATCH 3/6] test(render-node): read the node's last beat after its empty claim was answered The heartbeat check slept 300 ms to get past the claim that finds the queue empty and then gave heartbeats 400 ms to move the node's last sign of life: a slow runner could fail it, or pass it on the claim's own touch. It now counts the claims the server answered, reads the last beat after the third one, waits for a later beat with a deadline and checks that no claim came since. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- .../Jobs/RenderNodeClientTests.cs | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/tests/Titano.Server.Tests/Jobs/RenderNodeClientTests.cs b/tests/Titano.Server.Tests/Jobs/RenderNodeClientTests.cs index ef445c21..c32fecf2 100644 --- a/tests/Titano.Server.Tests/Jobs/RenderNodeClientTests.cs +++ b/tests/Titano.Server.Tests/Jobs/RenderNodeClientTests.cs @@ -101,18 +101,20 @@ public sealed class RenderNodeClientTests(TestContext context) var job = await CreateRenderAsync(server, editor, sequenceId, Mjpeg with { Batch = ["gif-preview"] }); var gif = (await server.Database.Jobs.ListAsync(JobState.Queued, JobKind.Render)).Items.Single(j => j.Id != job.Id); - using var client = new TitanoClient(server.HttpBase, new CertificatePinning([]), "studio-pc") { Token = token }; + var claims = new CountClaims(new SocketsHttpHandler()); + using var client = new TitanoClient(server.HttpBase, new CertificatePinning([]), "studio-pc", claims) { Token = token }; var cache = context.CreateTempDirectory("node"); // Claims only when started and after each job: between them only heartbeats reach the server. var node = Node(client, cache, poll: TimeSpan.FromMinutes(5), heartbeat: TimeSpan.FromMilliseconds(100)); node.Start(); await JobApiTests.WaitForAsync(editor, job.Id, "done"); await JobApiTests.WaitForAsync(editor, gif.Id, "done"); - // Past the claim that found the queue empty, only heartbeats move the node's last sign of life. - await Task.Delay(300); + // Past the claim that found the queue empty (the server touched the node before answering it), only heartbeats + // move the node's last sign of life. + await UntilAsync(() => Task.FromResult(claims.Answered >= 3), "the claim that found the queue empty"); var beat = (await server.Database.RenderNodes.ListAsync()).Single().LastHeartbeat; - await Task.Delay(400); - Assert.Greater((await server.Database.RenderNodes.ListAsync()).Single().LastHeartbeat.Ticks, beat.Ticks); + await UntilAsync(async () => (await server.Database.RenderNodes.ListAsync()).Single().LastHeartbeat > beat, "a heartbeat"); + Assert.Equal(3, claims.Answered, "no claim since the queue was empty"); await node.DisposeAsync(); Assert.True(node.Completion.IsCompleted, "stopped"); @@ -312,6 +314,21 @@ public sealed class RenderNodeClientTests(TestContext context) } } + /// Counts the node's claims the server answered. + private sealed class CountClaims(HttpMessageHandler inner) : DelegatingHandler(inner) + { + private int _answered; + + public int Answered => Volatile.Read(ref _answered); + + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var response = await base.SendAsync(request, cancellationToken); + if (request.RequestUri!.AbsolutePath.EndsWith("/claim", StringComparison.Ordinal)) Interlocked.Increment(ref _answered); + return response; + } + } + /// The first cut bytes, then a reset connection. private sealed class CutStream(byte[] data, int cut) : MemoryStream(data, 0, cut) { @@ -325,6 +342,16 @@ public sealed class RenderNodeClientTests(TestContext context) private static int Check(int read) => read > 0 ? read : throw new IOException("Connection reset by peer"); } + private static async Task UntilAsync(Func> condition, string what) + { + var until = DateTime.UtcNow.AddSeconds(30); + while (!await condition()) + { + if (DateTime.UtcNow > until) Assert.Fail("Timed out waiting for " + what); + await Task.Delay(25); + } + } + private static async Task CreateRenderAsync(TestServer server, HttpClient editor, Guid sequenceId, ExportSettings? export = null) { var sequence = (await server.Database.Sequences.GetAsync(sequenceId))!; From 9f03c07fdfe2cd378156f627edaa1f36ab8d1715 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 21:19:30 +0000 Subject: [PATCH 4/6] fix(server): the current log downloads while the server keeps writing it GET /api/v1/logs/files/{name} served the file with Results.File, which sets Content-Length from the file's size and then copies it to its end. The current log grows whenever the server logs, so a line written meanwhile made Kestrel abort the response ("too many bytes written"); AdminTests failed on it once in three full runs. The endpoint now sends the bytes the file held when it was listed through FileResponses.Serve, a fixed-length, range-capable slice. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- src/Titano.Server/Api/AdminEndpoints.cs | 7 +++-- tests/Titano.Server.Tests/Api/AdminTests.cs | 32 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/Titano.Server/Api/AdminEndpoints.cs b/src/Titano.Server/Api/AdminEndpoints.cs index 45826700..a575e7d5 100644 --- a/src/Titano.Server/Api/AdminEndpoints.cs +++ b/src/Titano.Server/Api/AdminEndpoints.cs @@ -29,10 +29,11 @@ public static class AdminEndpoints ProtocolJson.Default.ListLogFileDto)); logs.MapGet("/files/{name}", (HttpContext context, string name, ServerOptions options) => { - // Only names of existing log files are served: the name never becomes part of a path. + // Only names of existing log files are served: the name never becomes part of a path. The current log keeps + // growing while it is sent, so the response holds the bytes it had when listed, as its Content-Length says. if (LogFiles(options).FirstOrDefault(f => f.Name == name) is not { } file) return ApiErrors.NotFound(context, "log"); - context.Response.Headers.CacheControl = "no-store"; - return Results.File(file.FullName, "text/plain; charset=utf-8", file.Name, file.LastWriteTimeUtc, enableRangeProcessing: true); + return FileResponses.Serve(context, file, 0, file.Length, "text/plain; charset=utf-8", "no-store", downloadName: file.Name) + ?? ApiErrors.NotFound(context, "log"); }); } diff --git a/tests/Titano.Server.Tests/Api/AdminTests.cs b/tests/Titano.Server.Tests/Api/AdminTests.cs index e085f171..2f8b00e8 100644 --- a/tests/Titano.Server.Tests/Api/AdminTests.cs +++ b/tests/Titano.Server.Tests/Api/AdminTests.cs @@ -1,6 +1,8 @@ using System.Net; using System.Net.Http.Json; using System.Text.Json.Nodes; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Titano.Protocol; using Titano.Testing; @@ -66,6 +68,36 @@ public sealed class AdminTests(TestContext context) await traversal.ExpectErrorAsync(HttpStatusCode.NotFound, "not_found"); } + [Test] + public async Task TheCurrentLogDownloadsWhileTheServerKeepsLogging() + { + await using var server = await TestServer.StartAsync(context, o => o.LogLevel = Microsoft.Extensions.Logging.LogLevel.Information); + 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; + var logger = server.Services.GetRequiredService().CreateLogger("Titano.Server.Tests"); + using var stop = new CancellationTokenSource(); + // Jobs, uploads and sign-ins keep writing to the file an administrator downloads. + var logging = Task.Run(() => + { + while (!stop.IsCancellationRequested) logger.LogInformation("Busy"); + }); + try + { + for (var i = 0; i < 5; i++) + { + using var download = await admin.GetAsync($"/api/v1/logs/files/{name}"); + await download.ExpectAsync(HttpStatusCode.OK); + Assert.Equal(download.Content.Headers.ContentLength, (await download.Content.ReadAsByteArrayAsync()).LongLength); + } + } + finally + { + await stop.CancelAsync(); + await logging; + } + } + [Test] public async Task ArchiveSettingsValidateTemplatesAndJobsNeedHandlers() { From 5aa7ed1e6fa5034acf2203b3167bf23881193525 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 21:36:24 +0000 Subject: [PATCH 5/6] test(server): the busy-log test writes only to the server's log file Its logging loop also went to the console, whose lock the loggers of the test classes running alongside share: a job engine waiting to log a failure kept JobApiTests' job "running" past its 15 s deadline. The loop now writes through the server's file logger on a thread of its own. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- tests/Titano.Server.Tests/Api/AdminTests.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Titano.Server.Tests/Api/AdminTests.cs b/tests/Titano.Server.Tests/Api/AdminTests.cs index 2f8b00e8..3de0b7fe 100644 --- a/tests/Titano.Server.Tests/Api/AdminTests.cs +++ b/tests/Titano.Server.Tests/Api/AdminTests.cs @@ -4,6 +4,7 @@ using System.Text.Json.Nodes; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Titano.Protocol; +using Titano.Server.Hosting; using Titano.Testing; namespace Titano.Server.Tests.Api; @@ -75,13 +76,14 @@ 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; - var logger = server.Services.GetRequiredService().CreateLogger("Titano.Server.Tests"); + // 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. + var logger = server.Services.GetServices().OfType().Single().CreateLogger("Titano.Server.Tests"); using var stop = new CancellationTokenSource(); - // Jobs, uploads and sign-ins keep writing to the file an administrator downloads. - var logging = Task.Run(() => + var logging = Task.Factory.StartNew(() => { while (!stop.IsCancellationRequested) logger.LogInformation("Busy"); - }); + }, TaskCreationOptions.LongRunning); try { for (var i = 0; i < 5; i++) From bdcd4e42aeafbc82b8d95ad9ffcc11f4e28e4bcc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 22:03:31 +0000 Subject: [PATCH 6/6] 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 {