From 7d52787ce3d909231a77da9d98f558aa90576863 Mon Sep 17 00:00:00 2001 From: mus65 Date: Tue, 21 May 2024 13:05:46 +0200 Subject: [PATCH] make ConnectShouldActivateKeepAliveIfSessionIs test less flaky (#1410) * make ConnectShouldActivateKeepAliveIfSessionIs test less flaky wait longer and expect at least two instead of exactly two. example: https://ci.appveyor.com/project/drieseng/ssh-net/builds/49849877/job/9rrtw6j8eu3i5p8o?fullLog=true * fix net462 build --- ...tTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Renci.SshNet.Tests/Classes/BaseClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs b/test/Renci.SshNet.Tests/Classes/BaseClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs index b6276479..31e66f35 100644 --- a/test/Renci.SshNet.Tests/Classes/BaseClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs +++ b/test/Renci.SshNet.Tests/Classes/BaseClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs @@ -69,11 +69,11 @@ namespace Renci.SshNet.Tests.Classes _client.Connect(); - // allow keep-alive to be sent twice - Thread.Sleep(250); + // allow keep-alive to be sent at least twice with some margin for error + Thread.Sleep(5 * (int)_keepAliveInterval.TotalMilliseconds); - // Exactly two keep-alives should be sent - SessionMock.Verify(p => p.TrySendMessage(It.IsAny()), Times.Exactly(2)); + // At least two keep-alives should be sent + SessionMock.Verify(p => p.TrySendMessage(It.IsAny()), Times.AtLeast(2)); } private class MyClient : BaseClient