Fase 3 — Conti, ordini, contabilità #89
@@ -136,9 +136,11 @@ internal sealed class TestDb : IAsyncDisposable
|
||||
return new TestDb(new() { Engine = engine, SqlitePath = Path.Combine(folder, "test.sqlite3") }, folder, null);
|
||||
}
|
||||
|
||||
var name = "anubis_t_" + Guid.NewGuid().ToString("N");
|
||||
string name;
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
// A new name each time: a dropped connection may have created the database before the answer was lost.
|
||||
name = "anubis_t_" + Guid.NewGuid().ToString("N");
|
||||
try
|
||||
{
|
||||
await using var admin = Anubis.Db.Database.Open(AdminSettings());
|
||||
@@ -148,10 +150,10 @@ internal sealed class TestDb : IAsyncDisposable
|
||||
await command.ExecuteNonQueryAsync().ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
catch (Npgsql.NpgsqlException ex) when (ex.InnerException is TimeoutException && attempt < 4)
|
||||
catch (Npgsql.NpgsqlException ex) when (ex.IsTransient && attempt < 4)
|
||||
{
|
||||
// Many tests create their database at once and a busy CI runner can be slow to accept even within the
|
||||
// longer test timeout. That is the runner, not the code under test.
|
||||
// Many tests create their database at once and a busy CI runner can be slow to accept, or drop a
|
||||
// connection while its PostgreSQL service is still settling. That is the runner, not the code under test.
|
||||
await Task.Delay(TimeSpan.FromSeconds(attempt)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user