Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
halter73 committed Dec 30, 2020
1 parent f6167f8 commit 13b6369
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Servers/Kestrel/Core/test/HeartbeatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -22,7 +23,7 @@ public void HeartbeatIntervalIsOneSecond()
}

[Fact]
public async Task HeartbeatTakingLongerThanIntervalIsLoggedAsError()
public async Task HeartbeatTakingLongerThanIntervalIsLoggedAsWarning()
{
var systemClock = new MockSystemClock();
var heartbeatHandler = new Mock<IHeartbeatHandler>();
Expand Down Expand Up @@ -57,11 +58,16 @@ public async Task HeartbeatTakingLongerThanIntervalIsLoggedAsError()
await blockedHeartbeatTask.DefaultTimeout();

heartbeatHandler.Verify(h => h.OnHeartbeat(now), Times.Once());
Assert.Equal($"As of\"{now}\", the heartbeat has been running for \"{heartbeatDuration}\" which is longer than \"{Heartbeat.Interval}\". This could be caused by thread pool starvation.", kestrelTrace.Logger.Messages.Single(message => message.LogLevel == LogLevel.Warning).Message);

var warningMessage = kestrelTrace.Logger.Messages.Single(message => message.LogLevel == LogLevel.Warning).Message;
Assert.Equal($"As of \"{now.ToString(CultureInfo.InvariantCulture)}\", the heartbeat has been running for "
+ $"\"{heartbeatDuration.ToString("c", CultureInfo.InvariantCulture)}\" which is longer than "
+ $"\"{Heartbeat.Interval.ToString("c", CultureInfo.InvariantCulture)}\". "
+ "This could be caused by thread pool starvation.", warningMessage);
}

[Fact]
public async Task HeartbeatTakingLongerThanIntervalIsNotLoggedAsErrorIfDebuggerAttached()
public async Task HeartbeatTakingLongerThanIntervalIsNotLoggedIfDebuggerAttached()
{
var systemClock = new MockSystemClock();
var heartbeatHandler = new Mock<IHeartbeatHandler>();
Expand Down

0 comments on commit 13b6369

Please sign in to comment.