From fd4bddae28cd56459c9834f0414877975c7f67fa Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Mon, 20 May 2024 20:08:52 +0200 Subject: [PATCH 1/2] 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 --- ...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 b6276479d..ffd168910 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 @@ public void ConnectShouldActivateKeepAliveIfSessionIs() _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 * _keepAliveInterval); - // 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 From 662af82aee71e9d1f457baf77ee1c33afe907c0b Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Mon, 20 May 2024 22:24:58 +0200 Subject: [PATCH 2/2] fix net462 build --- ...eClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ffd168910..31e66f35e 100644 --- a/test/Renci.SshNet.Tests/Classes/BaseClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs +++ b/test/Renci.SshNet.Tests/Classes/BaseClientTest_NotConnected_KeepAliveInterval_NotNegativeOne.cs @@ -70,7 +70,7 @@ public void ConnectShouldActivateKeepAliveIfSessionIs() _client.Connect(); // allow keep-alive to be sent at least twice with some margin for error - Thread.Sleep(5 * _keepAliveInterval); + Thread.Sleep(5 * (int)_keepAliveInterval.TotalMilliseconds); // At least two keep-alives should be sent SessionMock.Verify(p => p.TrySendMessage(It.IsAny()), Times.AtLeast(2));