Fase 2 — Dati di mercato #88
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