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);
|
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++)
|
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
|
try
|
||||||
{
|
{
|
||||||
await using var admin = Anubis.Db.Database.Open(AdminSettings());
|
await using var admin = Anubis.Db.Database.Open(AdminSettings());
|
||||||
@@ -148,10 +150,10 @@ internal sealed class TestDb : IAsyncDisposable
|
|||||||
await command.ExecuteNonQueryAsync().ConfigureAwait(false);
|
await command.ExecuteNonQueryAsync().ConfigureAwait(false);
|
||||||
break;
|
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
|
// Many tests create their database at once and a busy CI runner can be slow to accept, or drop a
|
||||||
// longer test timeout. That is the runner, not the code under test.
|
// 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);
|
await Task.Delay(TimeSpan.FromSeconds(attempt)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user