fix(server): Windows startup test asks for PostgreSQL; TITANO_LOG_LEVEL

The connection-string test built options with the platform default,
which is SQLite on Windows, so it parsed a file path as a PostgreSQL
connection string. The server gains a log level setting
(TITANO_LOG_LEVEL, also in compose and the Unraid template); the test
servers log warnings only, which cuts the suite's output from 511 to 80
lines so failures stay findable in CI logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 13:20:03 +00:00
1 parent 34505dfe79
commit f4e2f285a9
7 files changed
+22 -4

No files matched your search

+2
View File
@@ -22,6 +22,8 @@ services:
TITANO_DB_PASSWORD: ${TITANO_DB_PASSWORD:?set TITANO_DB_PASSWORD in .env}
TITANO_TLS_MODE: auto
TITANO_SERVER_NAME: Titano Server
# Trace, Debug, Information, Warning or Error
TITANO_LOG_LEVEL: Information
PUID: ${PUID:-1000}
PGID: ${PGID:-1000}
TZ: ${TZ:-UTC}
+1
View File
@@ -35,6 +35,7 @@
<Config Name="Database TLS" Target="TITANO_DB_SSLMODE" Default="prefer" Mode="" Description="disable, prefer, require or verify-full." Type="Variable" Display="advanced" Required="false" Mask="false">prefer</Config>
<Config Name="TLS mode" Target="TITANO_TLS_MODE" Default="auto" Mode="" Description="auto (self-signed), pem (own certificate) or proxy (behind a reverse proxy)." Type="Variable" Display="advanced" Required="false" Mask="false">auto</Config>
<Config Name="Server name" Target="TITANO_SERVER_NAME" Default="Titano Server" Mode="" Description="Name shown to clients." Type="Variable" Display="advanced" Required="false" Mask="false">Titano Server</Config>
<Config Name="Log level" Target="TITANO_LOG_LEVEL" Default="Information" Mode="" Description="Trace, Debug, Information, Warning or Error." Type="Variable" Display="advanced" Required="false" Mask="false">Information</Config>
<Config Name="PUID" Target="PUID" Default="99" Mode="" Description="User id that owns files." Type="Variable" Display="advanced" Required="true" Mask="false">99</Config>
<Config Name="PGID" Target="PGID" Default="100" Mode="" Description="Group id that owns files." Type="Variable" Display="advanced" Required="true" Mask="false">100</Config>
<Config Name="Time zone" Target="TZ" Default="Europe/Rome" Mode="" Description="Time zone of logs and schedules." Type="Variable" Display="advanced" Required="false" Mask="false">Europe/Rome</Config>
@@ -51,6 +51,7 @@ public sealed class ServerOptions
("TITANO_LANG", nameof(Language), (o, v) => o.Language = v),
("TITANO_WORKERS", nameof(Workers), (o, v) => o.Workers = Math.Max(1, Int("TITANO_WORKERS", v))),
("TITANO_DISCOVERY", nameof(Discovery), (o, v) => o.Discovery = bool.Parse(v)),
("TITANO_LOG_LEVEL", nameof(LogLevel), (o, v) => o.LogLevel = Enum.Parse<LogLevel>(v, ignoreCase: true)),
];
public string ServerName { get; set; } = "Titano Server";
@@ -77,6 +78,9 @@ public sealed class ServerOptions
public string Language { get; set; } = "en";
public int Workers { get; set; } = Math.Max(1, Environment.ProcessorCount / 2);
public bool Discovery { get; set; } = true;
/// <summary>Least severe level written to the console and the log files.</summary>
public LogLevel LogLevel { get; set; } = LogLevel.Information;
public long MaxUploadBytes { get; set; } = 2L * 1024 * 1024 * 1024;
public int ChunkSizeBytes { get; set; } = 8 * 1024 * 1024;
public int JobHistoryDays { get; set; } = 90;
+3 -2
View File
@@ -36,16 +36,17 @@ public static class ServerHost
var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions { Args = args, ContentRootPath = AppContext.BaseDirectory });
builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(options.LogLevel);
builder.Logging.AddSimpleConsole(c => c.SingleLine = true);
builder.Logging.AddProvider(new FileLoggerProvider(new FileLogSink(options.LogPath, "server")));
builder.Logging.AddFilter("Microsoft.AspNetCore", Microsoft.Extensions.Logging.LogLevel.Warning);
builder.Logging.AddFilter("Microsoft.Hosting.Lifetime", Microsoft.Extensions.Logging.LogLevel.Information);
builder.Logging.AddFilter("Microsoft.Hosting.Lifetime", options.LogLevel > Microsoft.Extensions.Logging.LogLevel.Information ? options.LogLevel : Microsoft.Extensions.Logging.LogLevel.Information);
// The archive module registers first, so a missing piece stops the server before it touches the database.
configureServices?.Invoke(builder.Services);
RequireArchiveModule(builder.Services);
using var bootLoggerFactory = LoggerFactory.Create(l => l.AddSimpleConsole(c => c.SingleLine = true));
using var bootLoggerFactory = LoggerFactory.Create(l => l.AddSimpleConsole(c => c.SingleLine = true).SetMinimumLevel(options.LogLevel));
var bootLogger = bootLoggerFactory.CreateLogger("Titano.Server");
var certificate = CertificateStore.Load(options, bootLogger);
var database = ServerDatabase.OpenAsync(options, bootLogger, CancellationToken.None).GetAwaiter().GetResult();
+1 -1
View File
@@ -53,7 +53,7 @@ public sealed class AdminTests(TestContext context)
[Test]
public async Task LogsAreReadableButOnlyByName()
{
await using var server = await TestServer.StartAsync(context);
await using var server = await TestServer.StartAsync(context, o => o.LogLevel = Microsoft.Extensions.Logging.LogLevel.Information);
var admin = await server.AdminAsync();
using var tail = await admin.GetAsync("/api/v1/logs?lines=20");
var lines = await tail.ReadAsync(ProtocolJson.Default.LogTailDto);
@@ -44,7 +44,15 @@ public sealed class StartupTests(TestContext context)
[Test]
public void PartsBuildAQuotedPostgresConnectionString()
{
var options = new ServerOptions { DbHost = "postgres", DbName = "titano", DbUser = "titano", DbPassword = "it's;secret", DbSslMode = "disable" };
var options = new ServerOptions
{
Database = DatabaseKind.Postgres, // the Windows default is SQLite
DbHost = "postgres",
DbName = "titano",
DbUser = "titano",
DbPassword = "it's;secret",
DbSslMode = "disable",
};
var settings = Titano.Data.Postgres.PostgresSettings.Parse(options.ToDatabaseOptions().ConnectionString);
Assert.Equal(("postgres", "titano", "it's;secret"), (settings.Host, settings.Database, settings.Password));
Assert.Equal(Titano.Data.Postgres.SslMode.Disable, settings.SslMode);
+2
View File
@@ -66,6 +66,8 @@ public sealed class TestServer : IAsyncDisposable
AdminPassword = AdminPassword,
// Tests sign in many times from one address; the rate-limit test sets the production value.
LoginAttemptsPerMinute = 1000,
// Info lines of the ~55 servers the suite starts would bury failures in the CI log.
LogLevel = Microsoft.Extensions.Logging.LogLevel.Warning,
};
Directory.CreateDirectory(options.ArchivePath);
configure?.Invoke(options);