Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,18 @@ public async Task ConnectionFailure_RetriesInsteadOfCrashing()
});

var service = CreateService();
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20));

await service.StartAsync(cts.Token);

// The initial retry delay is 5s — wait long enough for at least one retry
await Task.Delay(TimeSpan.FromSeconds(7));
// The initial retry delay is 5s, so a second StartAsync invocation
// should land within ~5-6s of the first. Poll for the actual second
// call instead of sleeping a fixed window: the test then reflects the
// service's real retry timing rather than racing GitHub Actions
// scheduling overhead.
var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(15);
while (DateTime.UtcNow < deadline && callCount <= 1)
await Task.Delay(100);

// Should not have crashed the host — service retries
callCount.Should().BeGreaterThan(1, "the service should retry after connection failure");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,23 @@ public async Task FlushLoop_BatchesLogsToDatabase()
for (var i = 0; i < 5; i++)
logger.Log(LogLevel.Information, default, i, null, (s, _) => $"msg {s}");

// Wait for the 1-second flush timer to tick once.
await Task.Delay(1500);
// Poll for the flush loop to land at least one batch instead of waiting
// a fixed window past the 1-second timer tick. CI scheduling can stretch
// the timer's wakeup well past 1.5s; once any log is persisted we know
// the flush path is working and can stop waiting.
var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(15);
var landed = 0;
while (DateTime.UtcNow < deadline)
{
context.Reset();
landed = await context
.Logs.AsNoTracking()
.Where(l => l.Category == "TestCategory")
.CountAsync();
if (landed >= 1)
break;
await Task.Delay(50);
}
provider.Dispose();

context.Reset();
Expand Down
Loading