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 @@ -111,7 +111,10 @@ public async Task SQLServer_Not_Connected_Returns_Down_Status()
result.Description.Should().Be("SQL Server health check failed");
result.Details.Should().Contain("host", "localhost");
result.Details.Should().Contain("service", "Example");
result.Details.Should().ContainKey("error").WhoseValue.As<string>().Should().StartWith("SqlException: Connection Timeout Expired.");

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

[Fact(Skip = "Integration test - Requires local SQL Server instance")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task AddEurekaDiscoveryClient_UsesServerTimeout()
var appSettings = new Dictionary<string, string?>
{
["Eureka:Client:EurekaServer:ConnectTimeoutSeconds"] = "1",
["Eureka:Client:EurekaServer:RetryCount"] = "1"
["Eureka:Client:EurekaServer:RetryCount"] = "0"
Comment thread
bart-vmware marked this conversation as resolved.
};

IConfiguration configuration = new ConfigurationBuilder().AddInMemoryCollection(appSettings).Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ private async Task TimerLoopAsync(TimeSpan interval)

do
{
LogStartingRefreshCycle();

try
{
await _runner.RunAsync(isFirstTime, _timerTokenSource.Token);
}
catch (Exception exception) when (!exception.IsCancellation())
// A tick queued just before periodic refresh was disabled would still be delivered here.
// Checking the period prevents executing a stale tick when refresh has been turned off.
if (isFirstTime || _periodicTimer.Period != Timeout.InfiniteTimeSpan)
Comment thread
bart-vmware marked this conversation as resolved.
{
LogRefreshCycleFailed(exception);
LogStartingRefreshCycle();

try
{
await _runner.RunAsync(isFirstTime, _timerTokenSource.Token);
}
catch (Exception exception) when (!exception.IsCancellation())
{
LogRefreshCycleFailed(exception);
}
}

isFirstTime = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ public async Task Aggregates_contributors_in_parallel()
{
List<IHealthContributor> contributors =
[
new SlowContributor(1.Seconds()),
new SlowContributor(2.Seconds()),
new SlowContributor(3.Seconds())
new SlowContributor(3.Seconds()),
new SlowContributor(4.Seconds())
];

WebApplicationBuilder builder = TestWebApplicationBuilderFactory.Create();
Expand Down Expand Up @@ -408,7 +408,8 @@ public async Task Aggregates_contributors_in_parallel()
}
""");

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

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,30 @@ public sealed class EventPipeThreadDumperTest
public async Task Can_resolve_source_location_from_pdb()
{
using var backgroundCancellationSource = new CancellationTokenSource();
using var threadStarted = new ManualResetEventSlim(false);

var backgroundThread = new Thread(NestedType.BackgroundThreadCallback)
{
IsBackground = true
};

backgroundThread.Start(backgroundCancellationSource.Token);
backgroundThread.Start((backgroundCancellationSource.Token, threadStarted));
threadStarted.Wait(TestContext.Current.CancellationToken);

using var loggerProvider = new CapturingLoggerProvider();
using var loggerFactory = new LoggerFactory([loggerProvider]);
ILogger<EventPipeThreadDumper> logger = loggerFactory.CreateLogger<EventPipeThreadDumper>();

#if NET8_0
// Use a longer collection window on .NET 8 to compensate for the Sleep(0) yield.
var optionsMonitor = TestOptionsMonitor.Create(new ThreadDumpEndpointOptions
{
Duration = 100
Comment thread
bart-vmware marked this conversation as resolved.
});
#else
var optionsMonitor = new TestOptionsMonitor<ThreadDumpEndpointOptions>();
#endif

var dumper = new EventPipeThreadDumper(optionsMonitor, logger);

IList<ThreadInfo> threads = await dumper.DumpThreadsAsync(TestContext.Current.CancellationToken);
Expand Down Expand Up @@ -87,11 +98,18 @@ private static class NestedType
{
public static void BackgroundThreadCallback(object? argument)
{
var cancellationToken = (CancellationToken)argument!;
(CancellationToken cancellationToken, ManualResetEventSlim threadStarted) = ((CancellationToken, ManualResetEventSlim))argument!;

threadStarted.Set();

while (!cancellationToken.IsCancellationRequested)
{
Thread.Sleep(TimeSpan.FromMilliseconds(50));
// Only actively-running threads are shown in the thread dump, so we need to make sure the CPU is in use.
Thread.SpinWait(250);
#if NET8_0
// Yield to allow the EventPipe rundown thread to make progress on .NET 8.
Thread.Sleep(0);
#endif
}
}
}
Expand Down
Loading