From bebba2a11394e8d7e3015e18836a1064af64704f Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Thu, 20 Apr 2017 10:58:48 -0700 Subject: [PATCH] Make UnrootedConnectionsGetRemovedFromHeartbeat test less flaky (#1727) --- .../FrameConnectionManagerTests.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameConnectionManagerTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameConnectionManagerTests.cs index a97ad6062f..96d253065e 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameConnectionManagerTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameConnectionManagerTests.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests { public class FrameConnectionManagerTests { - [Fact(Skip = "Flaky test")] + [Fact] public void UnrootedConnectionsGetRemovedFromHeartbeat() { var connectionId = "0"; @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests }; // The FrameConnection constructor adds itself to the connection manager. - var ignore = new FrameConnection(new FrameConnectionContext + var frameConnection = new FrameConnection(new FrameConnectionContext { ServiceContext = serviceContext, ConnectionId = connectionId @@ -56,6 +56,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests Assert.Equal(1, connectionCount); trace.Verify(t => t.ApplicationNeverCompleted(connectionId), Times.Never()); + + // Ensure frameConnection doesn't get GC'd before this point. + GC.KeepAlive(frameConnection); } } }