Skip to content
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

vstest.console.exe fails test run with socket exception #1472

Closed
NateB2 opened this issue Mar 12, 2018 · 10 comments
Closed

vstest.console.exe fails test run with socket exception #1472

NateB2 opened this issue Mar 12, 2018 · 10 comments
Assignees
Labels

Comments

@NateB2
Copy link

NateB2 commented Mar 12, 2018

Description

Seemingly at random, our test run will fail with a socket connection error as follows:

vstest.console.exe, ProxyDataCollectionManager.InvokeDataCollectionServiceAction: TestPlatformException = System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.Stream.ReadByte()
   at System.IO.BinaryReader.ReadByte()
   at System.IO.BinaryReader.Read7BitEncodedInt()
   at System.IO.BinaryReader.ReadString()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.SocketCommunicationManager.ReceiveMessage()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.DataCollectionRequestSender.SendAfterTestRunStartAndGetResult(ITestMessageEventHandler runEventsHandler, Boolean isCancelled)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.ProxyDataCollectionManager.<>c__DisplayClass15_0.<AfterTestRunEnd>b__0()
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.ProxyDataCollectionManager.InvokeDataCollectionServiceAction(Action action, ITestMessageEventHandler runEventsHandler).

We never received this error until we migrated to 15.6.

Steps to reproduce

I'm not sure how to reproduce this reliably. We run it on an Azure VM with multiple VSTS agent instances installed, and it seems to happen more frequently when the VM resources are taxed, but occasionally it occurs when no other instances are performing tasks.

Expected behavior

Test run finishes successfully

Actual behavior

Test run fails

Diagnostic logs

Here are the diagnostic logs surrounding the error. If there is any other diagnostic information you need, let me know. https://gist.github.com/NateB2/f97f8da22492cfb4489ddef87a0946e2

Environment

Windows Server 2016, VS 2017 15.6, VSTS agent 2.129.1.

@ravarnamsft
Copy link

We are seeing a similar issue on VSTS. This fails the test run though all tests pass. Can we disable this datacollection via a parameter in runsettings or commandline argument to vstest

@stefanmsft
Copy link

Also seeing this IOException on VSTS, have been encountering it for the last two days. It seems to happen pretty frequently on builds - occasionally the exception is not thrown and the build succeeds. We're seeing the exact same exception as above.

@Aurelien-Thomas
Copy link

I currently got it 100% of the time on VSTS, sometimes 2 or 3 times per build when running unit tests

@Diminouille
Copy link

same thing here, we got it systematically. Our build pipeline is currently broken, goodbye continous feedback :(

@smadala smadala self-assigned this Mar 21, 2018
@smadala
Copy link
Contributor

smadala commented Mar 21, 2018

Primary investigation indicates this issue occurs when running datacollection(Code Coverage, Fakes, etc..) in parallel. To unblock, Please disable the parallel(MaxCpuCount in runsettings) option while running tests. I'm working on fix. Will let you know once fix is available.

@smadala
Copy link
Contributor

smadala commented Mar 28, 2018

Published Microsoft.TestPlatform.15.6.2 package with fix. You can get the latest test platform by using the Visual studio test platform installer task to try out the fix right away.

We are planning to fix this issue in VS 15.6 upcoming update.

@smadala smadala closed this as completed Mar 28, 2018
@NateB2
Copy link
Author

NateB2 commented Apr 12, 2018

We have ran builds with the fixed version since Monday, and no builds have failed due to the socket exception, so it appears to be fixed for us. Thanks!

@TestO2015
Copy link

TestO2015 commented Mar 6, 2019

We're experiencing the same socket exception intermittently, in ~30% of builds. Vstest.console.exe_SocketException.txt

Environment details: We're running VsTest in an Azure Pipeline on a Hosted Agent. We've tried VsTest versions 16.0.0, 15.8.0.

We have an issue raised as well with more details in: microsoft/azure-pipelines-tasks#9095

@sroe
Copy link

sroe commented Jul 24, 2019

Same here, using VS 2017 Test Platform 15.9.1.2019030503, I have to kill the vstest.console.exe-Processes to get another Unittest running.
Sometimes there are 2 processes spawned but I only run 1 Method with Test Explorer.
I will update von VS 2019 in a week and will look if it's buggy there too.
As a workaround I am adding PostBuild-Events to the Unit Test Project with cmd.exe /K "kill vstest.console.exe" but thats realy a hack, because its not with every testrun, sometimes you run 200 tests without a problem...

@TestO2015
Copy link

TestO2015 commented Aug 1, 2019

Hi @sroe,

We were able to resolve this issue in microsoft/azure-pipelines-tasks#9095.

The underlying error was covered up by the vstest.console.exe SocketException. And perhaps strangely, the underlying exception could be revealed by enabling a custom batch size. The underlying error was on our end.

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

No branches or pull requests

9 participants