Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f311ff2
feat: cross-process test log correlation via OTLP receiver (#4818)
thomhurst Apr 13, 2026
a32e2ad
fix: address code review findings on OTLP correlation PR
thomhurst Apr 13, 2026
13ee150
refactor: simplify after code review
thomhurst Apr 13, 2026
e3109a9
fix: gate CreateHttpClient override on EnableTelemetryCollection
thomhurst Apr 13, 2026
c3f804a
fix: address third-round review findings
thomhurst Apr 13, 2026
1f9ee36
docs: add telemetry correlation docs, enable by default
thomhurst Apr 13, 2026
8959f79
docs: note field ordering assumption in ParseResourceLogs
thomhurst Apr 13, 2026
b373da4
test: add thorough tests for OTLP log-to-test correlation
thomhurst Apr 13, 2026
ab164b9
fix: update public API snapshots for new InternalsVisibleTo entry
thomhurst Apr 14, 2026
4a9231d
feat: add OTLP integration tests and auto-inject telemetry env vars
thomhurst Apr 14, 2026
3aed4c2
refactor: simplify integration tests per code review
thomhurst Apr 14, 2026
dc20e0c
docs: address review feedback on shared handler and TraceId scope
thomhurst Apr 14, 2026
28d44bb
fix: generate unique TraceId per HTTP request for reliable correlation
thomhurst Apr 14, 2026
c40e230
feat: give each test its own TraceId via root activity with class link
thomhurst Apr 14, 2026
4359189
test: add engine activity tests, fix test body parent chain
thomhurst Apr 14, 2026
0587668
fix: restore parent-child activity hierarchy, move correlation to han…
thomhurst Apr 14, 2026
3e6575c
refactor: replace raw tag key strings with TUnitActivitySource constants
thomhurst Apr 14, 2026
3221c82
fix: replace fixed Task.Delay with polling in OtlpReceiverTests
thomhurst Apr 14, 2026
3ddbf74
fix: address review round 4 findings
thomhurst Apr 14, 2026
477a319
fix: remove mutually exclusive RunOnLinuxOnly/RunOnWindowsOnly attrs
thomhurst Apr 14, 2026
870a6c5
fix: add missing HangDump package to Aspire and ASP.NET test projects
thomhurst Apr 14, 2026
e911de2
fix: skip Aspire, ASP.NET, and RPC test modules on macOS
thomhurst Apr 14, 2026
3dd2b20
fix: enable Docker setup on macOS CI runners
thomhurst Apr 14, 2026
0874d0e
fix: skip Docker-dependent test modules on macOS
thomhurst Apr 14, 2026
87cfffa
fix: skip RPC tests globally until fixed (#5540)
thomhurst Apr 14, 2026
98fc40f
fix: restrict Docker-dependent CI modules to Linux, add missing ApiSe…
thomhurst Apr 14, 2026
08b62fb
fix: fix PublicAPI snapshot ordering and flaky severity test
thomhurst Apr 14, 2026
8c5e115
fix: move mock tests AOT publish into pipeline module
thomhurst Apr 14, 2026
068cdb0
Refactor code structure for improved readability and maintainability
thomhurst Apr 14, 2026
8034a5b
fix: share IntegrationTestFixture in WaitForHealthy tests
thomhurst Apr 14, 2026
f55d181
fix: restart Docker after setup to initialize iptables chains
thomhurst Apr 14, 2026
97178be
fix: remove docker/setup-docker-action
thomhurst Apr 14, 2026
4c3b872
fix: correct ASP.NET execution order assertions
thomhurst Apr 14, 2026
9145da5
fix: use CreateTablesAsync to avoid EnsureCreatedAsync race in parall…
thomhurst Apr 14, 2026
cad9f86
fix: use absolute path for AOT mock test publish output
thomhurst Apr 14, 2026
db8c9f9
merge: resolve conflict with main (NuGet.Protocol 7.3.1)
thomhurst Apr 14, 2026
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
Prev Previous commit
Next Next commit
fix: share IntegrationTestFixture in WaitForHealthy tests
WaitForHealthyReproductionTests was creating 2-3 separate Aspire
applications with Docker containers that ran concurrently with
IntegrationTestFixture. On CI, Docker contention caused the Aspire
SDK's internal 20s Polly timeout to fire during StartAsync, crashing
the fixture and failing all integration tests.

Refactor the Docker-dependent tests to share the session-wide
IntegrationTestFixture instead of creating their own apps.
  • Loading branch information
thomhurst committed Apr 14, 2026
commit 8034a5b79c23729720f3dd245b477184dcc30b38
75 changes: 38 additions & 37 deletions TUnit.Aspire.Tests/WaitForHealthyReproductionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Aspire.Hosting;
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.Testing;
using Microsoft.Extensions.DependencyInjection;
using TUnit.Assertions;
using TUnit.Assertions.Extensions;
Expand All @@ -10,30 +8,28 @@ namespace TUnit.Aspire.Tests;

/// <summary>
/// Reproduction and fix verification tests for https://github.com/thomhurst/TUnit/issues/5260
///
/// Docker-dependent tests share the session-wide <see cref="IntegrationTestFixture"/> so they
/// don't create competing Aspire applications. The remaining unit tests use in-memory fakes.
/// </summary>
public class WaitForHealthyReproductionTests
[ClassDataSource<IntegrationTestFixture>(Shared = SharedType.PerTestSession)]
public class WaitForHealthyReproductionTests(IntegrationTestFixture fixture)
{
[Test]
[Category("Docker")]
public async Task ParameterResource_DoesNotImplement_IResourceWithoutLifetime_InAspire13_2(CancellationToken ct)
public async Task ParameterResource_DoesNotImplement_IResourceWithoutLifetime_InAspire13_2()
{
await using var builder = await DistributedApplicationTestingBuilder.CreateAsync<Projects.TUnit_Aspire_Tests_AppHost>();
await using var app = await builder.BuildAsync();

var model = app.Services.GetRequiredService<DistributedApplicationModel>();
var model = fixture.App.Services.GetRequiredService<DistributedApplicationModel>();
var paramResource = model.Resources.First(r => r.Name == "my-secret");

await Assert.That(paramResource is IResourceWithoutLifetime).IsFalse();
}

[Test]
[Category("Docker")]
public async Task ParameterResource_IsNot_IComputeResource(CancellationToken ct)
public async Task ParameterResource_IsNot_IComputeResource()
{
await using var builder = await DistributedApplicationTestingBuilder.CreateAsync<Projects.TUnit_Aspire_Tests_AppHost>();
await using var app = await builder.BuildAsync();

var model = app.Services.GetRequiredService<DistributedApplicationModel>();
var model = fixture.App.Services.GetRequiredService<DistributedApplicationModel>();
var paramResource = model.Resources.First(r => r.Name == "my-secret");
var containerResource = model.Resources.First(r => r.Name == "nginx-no-healthcheck");

Expand All @@ -45,11 +41,7 @@ public async Task ParameterResource_IsNot_IComputeResource(CancellationToken ct)
[Category("Docker")]
public async Task WaitForResourceHealthyAsync_OnParameterResource_Hangs(CancellationToken ct)
{
await using var builder = await DistributedApplicationTestingBuilder.CreateAsync<Projects.TUnit_Aspire_Tests_AppHost>();
await using var app = await builder.BuildAsync();
await app.StartAsync(ct);

var notificationService = app.Services.GetRequiredService<ResourceNotificationService>();
var notificationService = fixture.App.Services.GetRequiredService<ResourceNotificationService>();

using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct);
cts.CancelAfter(TimeSpan.FromSeconds(15));
Expand All @@ -72,29 +64,43 @@ public async Task WaitForResourceHealthyAsync_OnParameterResource_Hangs(Cancella
await Assert.That(timedOut).IsTrue();
}

/// <summary>
/// Verifies the fix for #5260: <see cref="AspireFixture{TAppHost}.ShouldWaitForResource"/>
/// correctly filters out parameter resources and <see cref="IResourceWithParent"/>, so
/// <c>WaitForResourceHealthyAsync</c> completes on all waitable resources without hanging.
/// Uses the shared app instead of creating a new fixture to avoid Docker contention on CI.
/// </summary>
[Test]
[Category("Docker")]
public async Task AspireFixture_AllHealthy_Succeeds_AfterFix(CancellationToken ct)
public async Task AllHealthy_Succeeds_OnWaitableResources(CancellationToken ct)
{
var fixture = new HealthyFixture();
var notificationService = fixture.App.Services.GetRequiredService<ResourceNotificationService>();
var model = fixture.App.Services.GetRequiredService<DistributedApplicationModel>();

try
{
await fixture.InitializeAsync();
}
finally
// Apply the same filter that AspireFixture.ShouldWaitForResource uses
var waitableResources = model.Resources
.Where(r => r is IComputeResource && r is not IResourceWithParent)
.ToList();

using var cts = CancellationTokenSource.CreateLinkedTokenSource(ct);
cts.CancelAfter(TimeSpan.FromSeconds(60));

foreach (var resource in waitableResources)
{
await fixture.DisposeAsync();
await notificationService.WaitForResourceHealthyAsync(resource.Name, cts.Token);
}

// If we reach here, AllHealthy would succeed — the fix is working
await Assert.That(waitableResources).IsNotEmpty();
}

[Test]
public async Task ShouldWaitForResource_IncludesComputeResource()
{
var fixture = new InspectableFixture();
var inspectable = new InspectableFixture();
var regular = new FakeContainerResource("my-container");

await Assert.That(fixture.TestShouldWaitForResource(regular)).IsTrue();
await Assert.That(inspectable.TestShouldWaitForResource(regular)).IsTrue();
}

/// <summary>
Expand All @@ -107,25 +113,20 @@ public async Task ShouldWaitForResource_IncludesComputeResource()
[Test]
public async Task ShouldWaitForResource_ExcludesIResourceWithParent()
{
var fixture = new InspectableFixture();
var inspectable = new InspectableFixture();
var regular = new FakeContainerResource("my-container");
var rebuilder = new FakeRebuilderResource("my-container-rebuilder", regular);

await Assert.That(fixture.TestShouldWaitForResource(rebuilder)).IsFalse();
await Assert.That(inspectable.TestShouldWaitForResource(rebuilder)).IsFalse();
}

[Test]
public async Task ShouldWaitForResource_ExcludesNonComputeResource()
{
var fixture = new InspectableFixture();
var inspectable = new InspectableFixture();
var paramResource = new FakeNonComputeResource("my-param");

await Assert.That(fixture.TestShouldWaitForResource(paramResource)).IsFalse();
}

private sealed class HealthyFixture : AspireFixture<Projects.TUnit_Aspire_Tests_AppHost>
{
protected override TimeSpan ResourceTimeout => TimeSpan.FromSeconds(60);
await Assert.That(inspectable.TestShouldWaitForResource(paramResource)).IsFalse();
}

/// <summary>
Expand Down
Loading