Make two tests steady on a busy CI runner (refs #20 #25)
ci / test (postgres) (push) Successful in 2m48s
ci / test (sqlite) (push) Successful in 2m10s
ci / test (postgres) (pull_request) Failing after 3m37s
ci / test (sqlite) (pull_request) Successful in 2m20s
ci / image (pull_request) Skipped
ci / image (push) Successful in 21s

- The skipped-minute test waited for the recovered bar, but the issue is
  closed a moment after the bar is stored; on PostgreSQL in CI (run 181) it
  read the issue in between and saw it still open. It now waits for the
  issue's final state.
- Creating a PostgreSQL test database retries on a connection timeout: CI
  run 179 on main failed because twelve workers created their databases at
  once and one connection missed the application's 5-second timeout. The
  application's timeout is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-10 17:23:58 +01:00
1 parent de2cc0eedf
commit 094a527ba2
2 files changed
+20 -7

No files matched your search

+16 -5
View File
@@ -137,12 +137,23 @@ internal sealed class TestDb : IAsyncDisposable
}
var name = "anubis_t_" + Guid.NewGuid().ToString("N");
await using (var admin = Anubis.Db.Database.Open(AdminSettings()))
for (var attempt = 1; ; attempt++)
{
await using var connection = await admin.OpenConnectionAsync(CancellationToken.None).ConfigureAwait(false);
await using var command = connection.CreateCommand();
command.CommandText = $"CREATE DATABASE {name}";
await command.ExecuteNonQueryAsync().ConfigureAwait(false);
try
{
await using var admin = Anubis.Db.Database.Open(AdminSettings());
await using var connection = await admin.OpenConnectionAsync(CancellationToken.None).ConfigureAwait(false);
await using var command = connection.CreateCommand();
command.CommandText = $"CREATE DATABASE {name}";
await command.ExecuteNonQueryAsync().ConfigureAwait(false);
break;
}
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
// application's 5-second connection timeout to accept one. That is the runner, not the code under test.
await Task.Delay(TimeSpan.FromSeconds(attempt)).ConfigureAwait(false);
}
}
return new TestDb(AdminSettings() with { Database = name }, null, name);