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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
1 file changed
+6
-4
@@ -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<ILoggerFactory>().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<ILoggerProvider>().OfType<FileLoggerProvider>().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++)
|
||||
|
||||
Reference in new issue
Block a user