Add unit tests for task-based asynchronous API - #906
Conversation
|
I'm also seeing AppVeyor failing a lot due to port exhaustion - I mentioned this before on #877 (comment) |
…sConnectedAndChannelIsOpen
|
Still failing on AppVeyor, seems to be a different issue: |
|
Lots o' issues. :) That is the last non-sporadic one, hopefully it is fixed now... |
|
@drieseng, can you please have a look a this? In addition to adding coverage it also fixes a lot of transient errors, which blocks a lot of other PRs. |
drieseng
left a comment
There was a problem hiding this comment.
Overall this PR looks great.
I indicated a few changes that I'd like to move out of this PR.
In general, please try to have smaller PRs.
PS. I happen to get carried away myself, so don't hesitate to remind me of this as well (and reject my PRs for the same reason).
| public void SendMessageOnSessionShouldBeInvokedThreeTimes() | ||
| { | ||
| _sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(3)); | ||
| Assert.AreEqual(3, _actualKeepAliveCount); |
There was a problem hiding this comment.
Why do you prefer this over verifying the mock?
There was a problem hiding this comment.
It was the only way I found to stop this test failing sporadically for me. Let me remove non-Async changes from the PR and then we'll disuss, OK?
There was a problem hiding this comment.
OK. I flagged some other changes that you can keep in this PR.
| os: Visual Studio 2019 | ||
|
|
||
| init: | ||
| - netsh int ipv4 set dynamicport tcp start=1025 num=64510 |
There was a problem hiding this comment.
It was more of a "we open and close a lot of ports in tests and the tests are sporadically failing with connection failures, so more client-side ports can't hurt" line of reasoning.
| vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net40\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning" | ||
| vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net472\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning" | ||
|
|
||
| vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net35\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning" No newline at end of file |
There was a problem hiding this comment.
I'd first like to discuss dropping .NET 3.5 support.
Perhaps we'll have a final release supporting the legacy frameworks.
As I said, let's discuss this first.
|
|
||
| if (_channelThread != null) | ||
| { | ||
| if (_channelThread.IsAlive) |
There was a problem hiding this comment.
I suppose you did this because Thread.Abort is no longer supported on .NET (Core).
| _remoteWindowSize, | ||
| _remotePacketSize); | ||
|
|
||
| ManualResetEvent isReady = new ManualResetEvent(false); |
There was a problem hiding this comment.
I suppose this resolves an issue, but I always prefer to see the issue before a fix is applied for it.
| _pipeStream = new PipeStream {MaxBufferLength = 3}; | ||
|
|
||
| _writehread = new Thread(() => | ||
| ManualResetEvent isArranged = new ManualResetEvent(false); |
There was a problem hiding this comment.
I suppose this resolves an issue, but I always prefer to see the issue before a fix is applied for it.
Let's separate this and similar changes out.
| Assert.IsNotNull(_actualException); | ||
| Assert.IsNull(_actualException.InnerException); | ||
| Assert.AreEqual(SocketError.HostNotFound, _actualException.SocketErrorCode); | ||
| if (_actualException.SocketErrorCode != SocketError.TryAgain) |
There was a problem hiding this comment.
I suppose this resolves an issue, but I always prefer to see the issue before a fix is applied for it.
| Assert.IsNotNull(_actualException); | ||
| Assert.IsNull(_actualException.InnerException); | ||
| Assert.AreEqual(SocketError.HostNotFound, _actualException.SocketErrorCode); | ||
| if (_actualException.SocketErrorCode != SocketError.TryAgain) |
There was a problem hiding this comment.
I suppose this resolves an issue, but I always prefer to see the issue before a fix is applied for it.
| } | ||
| catch (SocketException ex) | ||
| { | ||
| if (ex.SocketErrorCode == SocketError.ConnectionAborted) |
There was a problem hiding this comment.
I suppose this resolves an issue, but I always prefer to see the issue before a fix is applied for it.
There was a problem hiding this comment.
I suppose this resolves an issue, but I always prefer to see the issue before a fix is applied for it.

I have created some unit tests for async API as a basis for discussion.
@drieseng can you please have a look if I'm kicking in the right direction?
Basically I plan to duplicate these tests:
Have I left out any major surface area?
I have removed unsupported targets from the Tests project. I have tried to list all the relevant (and supported) targets for each VS version. I've left net35 in as it is the last one running on 2.0 runtime.