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
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:
1 parent
de2cc0eedf
commit
094a527ba2
2 files changed
+20
-7
No files matched your search
@@ -165,11 +165,13 @@ public sealed class CollectorTests
|
||||
var skipped = new DateTimeOffset(2026, 11, 10, 10, 0, 0, TimeSpan.Zero);
|
||||
clock.Advance(TimeSpan.FromMinutes(2));
|
||||
await source.Live!.Writer.WriteAsync(new BarEvent("BTC-EUR", FakeMarketSource.MinuteBar(skipped.AddMinutes(1)), true)).ConfigureAwait(false);
|
||||
await OkxTests.WaitForAsync(() =>
|
||||
bars.MinuteAsync(btc.Id, skipped, skipped.AddMinutes(2), CancellationToken.None).GetAwaiter().GetResult().Count == 2).ConfigureAwait(false);
|
||||
// The minute is stored first and the issue closed right after: wait for the issue's final state.
|
||||
await OkxTests.WaitForAsync(() => issues.SinceAsync(DateTimeOffset.MinValue, CancellationToken.None).GetAwaiter().GetResult()
|
||||
.Any(i => i.Status != IssueStatus.Open)).ConfigureAwait(false);
|
||||
|
||||
var gap = (await issues.SinceAsync(DateTimeOffset.MinValue, CancellationToken.None).ConfigureAwait(false)).Single();
|
||||
Assert.AreEqual((IssueKinds.Gap, IssueStatus.Recovered, skipped), (gap.Kind, gap.Status, gap.StartsAt));
|
||||
Assert.AreEqual(2, (await bars.MinuteAsync(btc.Id, skipped, skipped.AddMinutes(2), CancellationToken.None).ConfigureAwait(false)).Count);
|
||||
await stop.CancelAsync().ConfigureAwait(false);
|
||||
await live.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user