-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Regression: dotnet test
hangs for 15 minutes after test run completed on mac and linux
#9452
Comments
I am not sure what you are doing in VSTS, but I suspect this might be long running servers that are still live when the test finishes. In 2.1.300, we now have a long running VBCSCompiler and a MSBuild node re-use server and a Razor compilation server. They all stay around for some time to avoid JITing and improve perf if you attempt a build again. You can turn them off by running |
Perhaps. But why would that prevent the tool from exiting?
How would I run that on VSTS after test execution, since test execution itself doesn't return control to the next step in my build till the 15 minutes are over?
I'm willing to try that. Where do I find the variables to set? And if it works, is that a bug in dotnet CLI then that it's waiting for those servers when the work is finished anyway? |
@peterhuene can you help @AArnott in getting the properties to turn off the long running servers? @AArnott I don't understand enough about how VSTS does test execution to know why it would consider as if test was not done in that case. |
Use Use For MSBuild, pass I don't know of anything that might be waiting on the servers. There was an issue where MSBuild might hang with node re-use enabled on non-Windows platforms (dotnet/msbuild#3161), but that was fixed for RTM. Would it be possible to capture the stacks of the hang? |
FWIW, I'm seeing hangs on Linux for |
This is to work around a Linux issue with .NET Core 2.1 https://github.com/dotnet/cli/issues/9397 (So far we haven't seen it hurt the Travis build, which may have it disabled by default.)
This is to work around a Linux issue with .NET Core 2.1 https://github.com/dotnet/cli/issues/9397 (So far we haven't seen it hurt the Travis build, which may have it disabled by default.)
I can confirm that setting |
FWIW, I vaguely recall a bug in a Windows process my team owned where a parent process spawned my child process, and so long as my child process was running the parent process never entirely exited. We fixed it (I don't remember how but could potentially find out). I wonder if something similar is happening here, where |
@rainersigwald Some reports of hitting hangs with node reuse above. |
This sounds exactly like what dotnet/msbuild@e604f5f addressed. But evidently that was incomplete or doesn't work everywhere. @jskeet @AArnott what's the best way for me to repro your cases? Can I just clone nodatime (before nodatime/nodatime#1157) and run |
@rainersigwald: I believe that should repro it, yes. You'll need to specify the targets to run - When it's broken, you should be able to run |
@jskeet Oh, that's interesting. It repros with I think I understand the environment, leading the build nodes to be created in a hangy way. But that wouldn't apply to |
@rainersigwald: I don't run But once it's in the "broken" state, then yes, I'm happy to try to get it into the broken state again and then poke around - are there diagnostics that would be useful to try at that point? |
I just want to chime in and say that I'm experiencing this issue as well. I haven't been able to reproduce it reliably yet, but I'll keep trying and once I do, I'll post a link to a repo here. The scenario I have is a unit test that is testing some MSBuild targets files. This involves calling
When running this via |
@reduckted You should be able to resolve that by calling |
Thanks @rainersigwald. 👍 I had tried that after reading some of the earlier posts and the hangs appeared to stop, but since I couldn't reliably reproduce it to begin with, I wasn't 100% sure it was the solution. |
FYI, this is happening for me on Ubuntu 18.04 and with dotnet 2.2.300. Passing
|
I can confirm that this still happens on .NET Core 3.1
|
This the exact spot where my test run also hangs. One interesting point I noticed is that the same code without changes runs in Visual Studio for Mac (the very first test method runs ok, and the others take 2+ minutes each - pure unit tests with mocking - so not even hitting the db). Not sure if that can help solve the issue. |
I too was facing the same issue where tests hang when executed through Visual Studio or through command line. In my case, the issue turned out to be happening because of a Nuget package I was using to generate Fake objects - AutoBogus . The library has an open issue for the same problem here AutoBogus Issue. When I switched the package to use Bogus the library which AutoBogus uses, it fixed the issue. My tests are running smoothly now. Sharing this here, just in case if it helps any one. |
I am still seeing this behavior on Azure DevOps with .NET Core 3.1.301 on a Windows Hosted Agent with VS2019 running dotnet test within a powershell script causes it to hang at the end of the execution. willing to share build and repro details. Eg: Get's stuck here for 40+ minutes |
I think I might have found the culprit. When run in an emacs shell
When run in xterm:
That 20 seconds in the first case is spent after the line |
Hey folks, i'm facing this issue too, i have a project with BDD tests using specflow and mocking external api's using wiremock.net, when the pipeline run the line |
This commit separates out the common test components from Elastic.Apm.Tests into a new assembly, Elastic.Apm.Tests.Utilities. This allows assemblies containing tests to be run in parallel, which is not possible when test assemblies reference another test assembly that may potentially be running at the same time. Update linux CI scripts to run tests by targeting the solution file. In conjunction with the xunit.runner.json configuration, this allows test assemblies to run in parallel. Add coverlet and JunitXml.TestLogger packages to all test projects using Directory.Build.Props in tests directory. This removes the need to add them in CI scripts or to each project individually. Update packages to newer versions. - Run tests with Release configuration - Include only Elastic.Apm.* and exclude all Elastic.Apm test assemblies from code coverage - Rename Elastic.Apm.DockerTests to Elastic.Apm.Docker.Tests for consistency - Rename Elastic.Apm.PerfTests to Elastic.Apm.Benchmarks - Use TestAgentComponents in test Update tests to use TestAgentComponents where possible, to mitigate intermittent failures with using AgentComponents related to reading environment variables that may be set by other concurrently running tests - Check token cancellation in Workloop check token cancellation in the BackendCommComponentBase Workloop, and break if cancellation is requested. - Don't Use SourceLink in coverlet.settings Jenkins cannot display Sourcelinked source code - Fix hanging tests Remove netcoreapp2.2 from tests. netcoreapp2.2 consistently hangs in CI on Linux due to MSBuild worker node reuse by dotnet test. This is the issue outlined in dotnet/sdk#9452 (comment). Setting `nodereuse:false` when running linux dotnet test on netcoreapp2.2 fixes the tests hanging, but since netcoreapp2.2 is EOL by Microsoft on December 23, 2019 (https://dotnet.microsoft.com/platform/support/policy/dotnet-core), netcoreapp2.2 has been removed from tests in line with the policy that we should only support versions that are supported by Microsoft.
Thank you. |
I've the same issue with WSL2 (ubuntu) on Windows 11 my test is using XUnit (2.4.2) and .NET 6 (6.0.301). Updating to |
Hi, I think lot of these issues are due to a bug in the In summary:
It looks like most of these issues happens when the dotnet sdk is summoned from another dotnet process, so with the Process class. |
This makes a lot of sense, since we're usually running our CI pipelines via NUKE, which is a .NET CLI app that calls the |
@bencef if you stilly happen to have this, check out microsoft/vstest#2080 (comment). Input redirection might solve your problem. |
Had the same on .Net 5 when running the tests in GitHub Actions for sonarscanner. Here is what I changed in the steps to get it working:
Maybe it helps someone in the same situation. |
Can you please explain @ana-cozma what exactly did you change? The steps you included seem pretty standard to me, unless you have something special in the runsettings file. |
Seems like passing Also from here seems like running the binary directly inside a container (eg as a dockerfile entrypoint, or in my case directly with kubectl exec inside a running kubernetes pod), not wrapping it into a bash call, seems to invoke the issue somehow, whereas wrapping it into a bash call seems to alleviate it. Maybe bash somehow helps with theese stdin/stdout streams deadlocks? |
Well, none of the workarounds actually worked for me. Seemed sometimes like it worked, but on one of the next runs it just hung again. Honestly, I'm at a loss. |
Do, by any chance, any of the tests hanging use TestServer (Mvc.Testing library) with IHostedService involved? Mine do. |
Not in my case, no. |
@Evengard Try the https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test Filter flag is optional, but useful to limit the tests you want to run.
|
The fact is that after 15 minutes all tests are completed successfully! It's not tests which are hanging, I see all the reports of all tests actually executing successfully. It's that after that dotnet test just hangs before terminating. |
I see, that is probably a different case then. I would still give If not, the next I would try is method of elimination to find the smallest subset of tests that consistently provoke this behavior. |
But I think I found a workaround for now: #27106 (comment) |
Still having this issue locally and in Azure Pipelines / VSTS. In my case it hangs for 20+ minutes without any feedback from the console.
It takes the full execution time BEFORE This happens every single time and can take 35+ minutes even when trying to run them locally. Using all the latest packages in the test project as well:
Adding When using
Anything else I can provide or test? |
Any updates? |
I abandoned Coverlet (I also tried a few others and they all take forever to instrument) and settled on just using Microsoft.CodeCoverage which is slightly more complex to configure but runs perfectly. Made small modifications to Microsoft's sample runsettings file to just include my assembly pattern like this:
And also default the format to Cobertura so the rest of the pipeline tools still work as they did with Coverlet.
Finally, add the runsettings file to your test
The results speak for themselves. |
this helped me. SQL provider mock was missing in my test...it got stuck forever |
Just a heads up, the problem went away for me completely when I migrated to dotnet 8 |
A glimmer of hope for those still stuck on this:
|
Our builds on VSTS include
dotnet test
, which restores, builds, and tests our product. With dotnet CLI 2.1.100 all went well. But when we upgraded to 2.1.300, the dotnet tool doesn't exit for 15 minutes after the test run is completed with no output to explain the delay.Expected behavior
The dotnet tool exits immediately, as can be seen on this 2.1.100 run:
Actual behavior
The dotnet tool exits after waiting 15 minutes, as can be seen on this 2.1.300 run:
Steps to reproduce
Please contact me via my microsoft.com email address for links to the builds if you'd like to investigate further.
The text was updated successfully, but these errors were encountered: