Skip to content
Merged
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
30 changes: 28 additions & 2 deletions TUnit.Aspire/AspireFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ protected virtual async Task WaitForResourcesAsync(DistributedApplication app, C
case ResourceWaitBehavior.AllHealthy:
{
var model = app.Services.GetRequiredService<DistributedApplicationModel>();
var names = model.Resources.Select(r => r.Name).ToList();
var names = GetWaitableResourceNames(model);
await WaitForResourcesWithFailFastAsync(app, notificationService, names, waitForHealthy: true, cancellationToken);
break;
}

case ResourceWaitBehavior.AllRunning:
{
var model = app.Services.GetRequiredService<DistributedApplicationModel>();
var names = model.Resources.Select(r => r.Name).ToList();
var names = GetWaitableResourceNames(model);
await WaitForResourcesWithFailFastAsync(app, notificationService, names, waitForHealthy: false, cancellationToken);
break;
}
Expand Down Expand Up @@ -523,6 +523,32 @@ private async Task<string> CollectResourceLogsAsync(
return string.Join(Environment.NewLine, lines);
}

private List<string> GetWaitableResourceNames(DistributedApplicationModel model)
{
var waitable = new List<string>();
List<string>? skipped = null;

foreach (var r in model.Resources)
{
if (r is IResourceWithoutLifetime)
{
skipped ??= [];
skipped.Add(r.Name);
}
else
{
waitable.Add(r.Name);
}
}

if (skipped is { Count: > 0 })
{
LogProgress($"Skipping {skipped.Count} resource(s) without lifecycle: [{string.Join(", ", skipped)}]");
}

return waitable;
}

private sealed class ResourceLogWatcher(CancellationTokenSource cts) : IAsyncDisposable
{
public ValueTask DisposeAsync()
Expand Down
Loading