Skip to content
Merged
Show file tree
Hide file tree
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: replace fixed Task.Delay with polling in OtlpReceiverTests
Replace brittle Task.Delay(200/300) waits with a PollForOutput helper
that polls test output until the expected content appears, avoiding
flaky failures on slow CI agents. Also remove redundant
EnableTelemetryCollection override in IntegrationTestFixture since
the base class already defaults to true.
  • Loading branch information
thomhurst committed Apr 14, 2026
commit 3221c82ab630311212092f2b7867cdf7a591bab9
2 changes: 0 additions & 2 deletions TUnit.Aspire.Tests/IntegrationTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace TUnit.Aspire.Tests;
/// </summary>
public class IntegrationTestFixture : AspireFixture<Projects.TUnit_Aspire_Tests_AppHost>
{
protected override bool EnableTelemetryCollection => true;

protected override TimeSpan ResourceTimeout => TimeSpan.FromSeconds(120);

protected override ResourceWaitBehavior WaitBehavior => ResourceWaitBehavior.AllRunning;
Expand Down
49 changes: 30 additions & 19 deletions TUnit.Aspire.Tests/OtlpReceiverTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Net;
using TUnit.Aspire.Telemetry;
using TUnit.Aspire.Tests.Helpers;
Expand Down Expand Up @@ -90,12 +91,8 @@ public async Task Receiver_CorrelatesLogs_ToCorrectTestOutput()

await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);

// Allow async processing to complete
await Task.Delay(200);

// Assert: the log should appear in this test's output
var output = testContext.GetStandardOutput();
await Assert.That(output).Contains("Hello from the SUT!");
var output = await PollForOutput(testContext, "Hello from the SUT!");
await Assert.That(output).Contains("[my-api]");
await Assert.That(output).Contains("[INFO]");
}
Expand All @@ -122,9 +119,8 @@ public async Task Receiver_CorrelatesLogs_MultipleSeverityLevels()
content.Headers.ContentType = new("application/x-protobuf");

await client.PostAsync($"http://127.0.0.1:{receiver.Port}/v1/logs", content);
await Task.Delay(200);

var output = testContext.GetStandardOutput();
var output = await PollForOutput(testContext, "Error message");
await Assert.That(output).Contains("[DEBUG] Debug message");
await Assert.That(output).Contains("[INFO] Info message");
await Assert.That(output).Contains("[ERROR] Error message");
Expand Down Expand Up @@ -154,8 +150,9 @@ public async Task Receiver_IgnoresLogs_WithUnknownTraceId()
content.Headers.ContentType = new("application/x-protobuf");

await client.PostAsync($"http://127.0.0.1:{receiver.Port}/v1/logs", content);
await Task.Delay(200);

// No matching trace ID — give a short window then verify nothing appeared
await Task.Delay(200);
var output = testContext.GetStandardOutput();
await Assert.That(output).DoesNotContain("This should not appear in test output");
}
Expand All @@ -181,13 +178,11 @@ public async Task Receiver_CorrelatesLogs_FromMultipleResources_ToSameTest()
content.Headers.ContentType = new("application/x-protobuf");

await client.PostAsync($"http://127.0.0.1:{receiver.Port}/v1/logs", content);
await Task.Delay(200);

var output = testContext.GetStandardOutput();
var output = await PollForOutput(testContext, "Backend processing request");
await Assert.That(output).Contains("[api-gateway]");
await Assert.That(output).Contains("Gateway received request");
await Assert.That(output).Contains("[backend-api]");
await Assert.That(output).Contains("Backend processing request");
}

[Test]
Expand Down Expand Up @@ -219,10 +214,8 @@ public async Task Receiver_CorrelatesLogs_ConcurrentTests_NoBleedBetweenTests()
content.Headers.ContentType = new("application/x-protobuf");

await client.PostAsync($"http://127.0.0.1:{receiver.Port}/v1/logs", content);
await Task.Delay(200);

var output = testContext.GetStandardOutput();
await Assert.That(output).Contains("My log");
var output = await PollForOutput(testContext, "My log");
// The other test's log should NOT appear in this test's output
// (it targets a non-existent TestContext, so it's silently dropped)
await Assert.That(output).DoesNotContain("Other test's log");
Expand Down Expand Up @@ -253,10 +246,9 @@ public async Task Receiver_LogWithNoResourceName_FormatsWithoutPrefix()
content.Headers.ContentType = new("application/x-protobuf");

await client.PostAsync($"http://127.0.0.1:{receiver.Port}/v1/logs", content);
await Task.Delay(200);

var output = testContext.GetStandardOutput();
// Should have severity but no resource prefix
var output = await PollForOutput(testContext, "Warning without service name");
await Assert.That(output).Contains("[WARN] Warning without service name");
}

Expand Down Expand Up @@ -322,9 +314,7 @@ public async Task Receiver_HandlesMultipleSequentialRequests()
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);
}

await Task.Delay(300);

var output = testContext.GetStandardOutput();
var output = await PollForOutput(testContext, "Request 4");
for (var i = 0; i < 5; i++)
{
await Assert.That(output).Contains($"Request {i}");
Expand All @@ -347,4 +337,25 @@ public async Task Receiver_MalformedProtobuf_Returns200_SilentlySkips()
// Should still return 200 (malformed protobuf is silently skipped)
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK);
}

/// <summary>
/// Polls test output until it contains the expected text or a timeout is reached.
/// Replaces fixed <c>Task.Delay</c> waits to avoid flaky timing on slow CI agents.
/// </summary>
private static async Task<string> PollForOutput(TestContext testContext, string expected, int timeoutMs = 5000)
{
var sw = Stopwatch.StartNew();
while (sw.ElapsedMilliseconds < timeoutMs)
{
var output = testContext.GetStandardOutput();
if (output.Contains(expected))
{
return output;
}

await Task.Delay(50);
}

return testContext.GetStandardOutput();
}
}
Loading