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