Skip to content

Unstable test ForwardedPortShouldAcceptNewConnections #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
WojciechNagorski opened this issue May 7, 2023 · 3 comments
Open

Unstable test ForwardedPortShouldAcceptNewConnections #1115

WojciechNagorski opened this issue May 7, 2023 · 3 comments

Comments

@WojciechNagorski
Copy link
Collaborator

One test is still unstable. The following test failed on master:

[00:05:13]   Passed IsStartedShouldReturnTrue [6 ms]
[00:05:13]   Failed ForwardedPortShouldAcceptNewConnections [43 ms]
[00:05:13]   Error Message:
[00:05:13]    Test method Renci.SshNet.Tests.Classes.ForwardedPortRemoteTest_Start_PortStarted.ForwardedPortShouldAcceptNewConnections threw exception: 
[00:05:13] Moq.MockException: 
[00:05:13] Expected invocation on the mock once, but was 0 times: p => p.CreateChannelForwardedTcpip(1655820009, 1225918901, 757994702)
[00:05:13] 
[00:05:13] Performed invocations:
[00:05:13] 
[00:05:13]    Mock<ISession:319> (p):
[00:05:13] 
[00:05:13]       ISession.IsConnected
[00:05:13]       ISession.add_ErrorOccured(EventHandler<ExceptionEventArgs>)
[00:05:13]       ISession.RegisterMessage("SSH_MSG_REQUEST_FAILURE")
[00:05:13]       ISession.RegisterMessage("SSH_MSG_REQUEST_SUCCESS")
[00:05:13]       ISession.RegisterMessage("SSH_MSG_CHANNEL_OPEN")
[00:05:13]       ISession.add_RequestSuccessReceived(EventHandler<MessageEventArgs<RequestSuccessMessage>>)
[00:05:13]       ISession.add_RequestFailureReceived(EventHandler<MessageEventArgs<RequestFailureMessage>>)
[00:05:13]       ISession.add_ChannelOpenReceived(EventHandler<MessageEventArgs<ChannelOpenMessage>>)
[00:05:13]       ISession.SendMessage(SSH_MSG_GLOBAL_REQUEST)
[00:05:13]       ISession.WaitOnHandle(AutoResetEvent)
[00:05:13]       ISession.CreateChannelForwardedTcpip(1655820009, 1225918901, 757994702)  => Mock<IChannelForwardedTcpip:17>
[00:05:13] 
[00:05:13]    Mock<IChannelForwardedTcpip:17>:
[00:05:13] 
[00:05:13]       IChannelForwardedTcpip.add_Exception(EventHandler<ExceptionEventArgs>)
[00:05:13]       IChannelForwardedTcpip.Bind(193.168.1.5:25065, ForwardedPortRemote)
[00:05:13]       IDisposable.Dispose()
[00:05:13] 
[00:05:13]   Stack Trace:
[00:05:13]       at Moq.Mock.Verify(Mock mock, LambdaExpression expression, Times times, String failMessage) in C:\projects\moq4\src\Moq\Mock.cs:line 316
[00:05:13]    at Moq.Mock`1.Verify[TResult](Expression`1 expression, Func`1 times) in C:\projects\moq4\src\Moq\Mock`1.cs:line 840
[00:05:13]    at Renci.SshNet.Tests.Classes.ForwardedPortRemoteTest_Start_PortStarted.ForwardedPortShouldAcceptNewConnections() in C:\projects\ssh-net\src\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest_Start_PortStarted.cs:line 142
[00:05:13]    at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
[00:05:13]    at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
[00:05:13] 
@WojciechNagorski
Copy link
Collaborator Author

Closed by #1185

@WojciechNagorski
Copy link
Collaborator Author

@Rob-Hague This fix does not work. https://ci.appveyor.com/project/drieseng/ssh-net/builds/48717243/job/k3xgumt7lhi8dfbl?fullLog=true

  Failed ForwardedPortShouldAcceptNewConnections [31 ms]
  Error Message:
   Test method Renci.SshNet.Tests.Classes.ForwardedPortRemoteTest_Start_PortNeverStarted.ForwardedPortShouldAcceptNewConnections threw exception: 
Moq.MockException: 
Expected invocation on the mock once, but was 0 times: p => p.Dispose()
Performed invocations:
   Mock<IChannelForwardedTcpip:16> (p):
      IChannelForwardedTcpip.add_Exception(EventHandler<ExceptionEventArgs>)
      IChannelForwardedTcpip.Bind(193.168.1.5:8940, ForwardedPortRemote)
      IDisposable.Dispose()
  Stack Trace:
      at Moq.Mock.Verify(Mock mock, LambdaExpression expression, Times times, String failMessage) in C:\projects\moq4\src\Moq\Mock.cs:line 330
   at Moq.Mock`1.Verify(Expression`1 expression, Times times) in C:\projects\moq4\src\Moq\Mock`1.cs:line 727
   at Moq.Mock`1.Verify(Expression`1 expression, Func`1 times) in C:\projects\moq4\src\Moq\Mock`1.cs:line 741
   at Renci.SshNet.Tests.Classes.ForwardedPortRemoteTest_Start_PortNeverStarted.ForwardedPortShouldAcceptNewConnections() in C:\projects\ssh-net\test\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest_Start_PortNeverStarted.cs:line 127
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
  Passed ClosingShouldNeverHaveFired [5 ms]
  Passed ExceptionShouldNotHaveFired [6 ms]

@Rob-Hague
Copy link
Collaborator

It's actually a different test

Renci.SshNet.Tests.Classes.ForwardedPortRemoteTest_Start_PortStarted.ForwardedPortShouldAcceptNewConnections
vs
Renci.SshNet.Tests.Classes.ForwardedPortRemoteTest_Start_PortNeverStarted.ForwardedPortShouldAcceptNewConnections

I think Thread.Sleep would work here as well. The problem is that the work in ForwardedPortRemote is dispatched onto another thread:

ThreadAbstraction.ExecuteThread(() =>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants