Fase 2 — Dati di mercato #88

Merged
Alby96 merged 11 commits from fase-2 into main 2026-11-10 17:53:14 +01:00
3 changed files with 10 additions and 3 deletions
Showing only changes of commit 1a8d48212f - Show all commits

No files matched your search

+1 -1
View File
@@ -79,7 +79,7 @@ public sealed class Database : IAsyncDisposable
Username = settings.User, Username = settings.User,
Password = settings.Password, Password = settings.Password,
}; };
pg.Timeout = 5; pg.Timeout = settings.ConnectTimeoutSeconds;
pg.CommandTimeout = 60; pg.CommandTimeout = 60;
pg.ApplicationName = "anubis"; pg.ApplicationName = "anubis";
var dataSource = new NpgsqlDataSourceBuilder(pg.ToString()).Build(); var dataSource = new NpgsqlDataSourceBuilder(pg.ToString()).Build();
+3
View File
@@ -33,6 +33,9 @@ public sealed record DbSettings
/// <summary>A full PostgreSQL address (<c>ANUBIS_DB_URL</c>) that replaces the five fields.</summary> /// <summary>A full PostgreSQL address (<c>ANUBIS_DB_URL</c>) that replaces the five fields.</summary>
public string? Url { get; init; } public string? Url { get; init; }
/// <summary>Seconds to wait for a new PostgreSQL connection. Short, so a lost server shows quickly; tests raise it.</summary>
public int ConnectTimeoutSeconds { get; init; } = 5;
/// <summary>What the interface shows: engine and place, never the password.</summary> /// <summary>What the interface shows: engine and place, never the password.</summary>
public string Describe() => Engine switch public string Describe() => Engine switch
{ {
+6 -2
View File
@@ -150,8 +150,8 @@ internal sealed class TestDb : IAsyncDisposable
} }
catch (Npgsql.NpgsqlException ex) when (ex.InnerException is TimeoutException && attempt < 4) catch (Npgsql.NpgsqlException ex) when (ex.InnerException is TimeoutException && attempt < 4)
{ {
// Many tests create their database at once: on a busy CI runner PostgreSQL can take longer than the // Many tests create their database at once and a busy CI runner can be slow to accept even within the
// application's 5-second connection timeout to accept one. That is the runner, not the code under test. // longer test timeout. That is the runner, not the code under test.
await Task.Delay(TimeSpan.FromSeconds(attempt)).ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(attempt)).ConfigureAwait(false);
} }
} }
@@ -170,6 +170,10 @@ internal sealed class TestDb : IAsyncDisposable
Database = "anubis", Database = "anubis",
User = "anubis", User = "anubis",
Password = PostgresPassword, Password = PostgresPassword,
// Twelve test workers open connections at once: on a busy CI runner PostgreSQL can take longer than the
// application's 5 seconds to accept one. Waiting longer here tests the same code without the runner's noise.
ConnectTimeoutSeconds = 30,
}; };
public async ValueTask DisposeAsync() public async ValueTask DisposeAsync()