Skip to content

Commit e2c698a

Browse files
committed
PR Feedback
- allow more time for parallel health check - threadReady -> threadStarted - keep changes for net8 specific to net8
1 parent c2403ca commit e2c698a

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/Connectors/test/Connectors.Test/RelationalDatabaseHealthContributorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public async Task SQLServer_Not_Connected_Returns_Down_Status()
113113
result.Details.Should().Contain("service", "Example");
114114

115115
result.Details.Should().ContainKey("error").WhoseValue.As<string>().Should().Match(exception =>
116-
exception.StartsWith("SqlException: Connection Timeout Expired.", StringComparison.InvariantCulture) ||
117-
exception.StartsWith("SqlException: A network-related or instance-specific error", StringComparison.InvariantCulture));
116+
exception.StartsWith("SqlException: Connection Timeout Expired.", StringComparison.Ordinal) ||
117+
exception.StartsWith("SqlException: A network-related or instance-specific error", StringComparison.Ordinal));
118118
}
119119

120120
[Fact(Skip = "Integration test - Requires local SQL Server instance")]

src/Management/test/Endpoint.Test/Actuators/Health/HealthAggregationTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ public async Task Aggregates_contributors_in_parallel()
408408
}
409409
""");
410410

411-
stopwatch.Elapsed.Should().BeGreaterThan(500.Milliseconds()).And.BeLessThan(6.Seconds());
411+
// Upper bound must be less than 2+3+4=9s if contributors ran sequentially.
412+
stopwatch.Elapsed.Should().BeGreaterThan(500.Milliseconds()).And.BeLessThan(9.Seconds());
412413
}
413414

414415
[Fact]

src/Management/test/Endpoint.Test/Actuators/ThreadDump/EventPipeThreadDumperTest.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ public async Task Can_resolve_source_location_from_pdb()
3030
using var loggerFactory = new LoggerFactory([loggerProvider]);
3131
ILogger<EventPipeThreadDumper> logger = loggerFactory.CreateLogger<EventPipeThreadDumper>();
3232

33-
// Use a longer collection window to provide enough sample opportunities on a loaded CI runner.
33+
#if NET8_0
34+
// Use a longer collection window on .NET 8 to compensate for the Sleep(0) yield.
3435
var optionsMonitor = TestOptionsMonitor.Create(new ThreadDumpEndpointOptions
3536
{
3637
Duration = 100
3738
});
39+
#else
40+
var optionsMonitor = new TestOptionsMonitor<ThreadDumpEndpointOptions>();
41+
#endif
3842

3943
var dumper = new EventPipeThreadDumper(optionsMonitor, logger);
4044

@@ -94,16 +98,18 @@ private static class NestedType
9498
{
9599
public static void BackgroundThreadCallback(object? argument)
96100
{
97-
(CancellationToken cancellationToken, ManualResetEventSlim threadReady) = ((CancellationToken, ManualResetEventSlim))argument!;
101+
(CancellationToken cancellationToken, ManualResetEventSlim threadStarted) = ((CancellationToken, ManualResetEventSlim))argument!;
98102

99-
threadReady.Set();
103+
threadStarted.Set();
100104

101105
while (!cancellationToken.IsCancellationRequested)
102106
{
103107
// Only actively-running threads are shown in the thread dump, so we need to make sure the CPU is in use.
104-
// Thread.Sleep(0) yields to allow the EventPipe rundown thread to make progress on .NET 8.
105108
Thread.SpinWait(250);
109+
#if NET8_0
110+
// Yield to allow the EventPipe rundown thread to make progress on .NET 8.
106111
Thread.Sleep(0);
112+
#endif
107113
}
108114
}
109115
}

0 commit comments

Comments
 (0)