-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Test running spins indefinitely when exception thrown from resilience pipeline #1018
Comments
What do you mean by |
It's a retry method encouraged by MS: https://learn.microsoft.com/en-us/dotnet/core/resilience/?tabs=dotnet-cli The short version is that it creates a cyclic stack trace when it throws multiple exceptions (the pipeline retries fail). |
I span up a PR to try to resolve the issue, I think I found the source (json serialization), but I'm not certain is I'm very new to this project: #1020 |
The change you've made is only for the rpc tests. If you're experiencing an issue with standard test execution then the rpc test project is completely separate to that so wouldn't resolve it |
Ah, you're right, my test isn't an RPC test. I'll cancel the PR, though you might want to consider adding that in later to ensure correct serialization when types are cyclical. Is there anything else I can grab from my test runs that might help locate the issue? |
You say it works normally - can you provide source code with this resilience pipeline? I'm unfamiliar with it |
The smallest toy example I can make quickly is without a pipeline:
When running this via TUnit it never finishes running the test for me. |
Just in case it's relevant, here is the csproj file used when I made that test:
|
Thanks! I'm out right now so it might be a couple of days before I can look but I'll get on it when I have a chance |
I embedded the test in TUnit.TestProject, I can break on all the pre test running lines, but as soon as the exception is thrown it vanishes into the ether. I'm starting to wonder is this is a deeper problem than the library, but in the new testing platform. If you think of a way for me to easily verify this while you're away please let me know! |
It very well could be the new testing platform. Since you think it's related to the json rpc, TUnit doesn't deal with that specifically. And since I might not be available for a couple of days, would you be able to also raise it with Microsoft regarding the new platform? Their repo is https://github.com/microsoft/testfx |
Confirmed to exist in the latest version of MSTest, so it seems as though it's an underlying issue. |
Glad to know it's not TUnit haha. But also hoping it gets solved soon! |
Fingers crossed! It's killing my commit tests atm, I just swapped to TUnit and the new platform. Now do decorate all of my tests with timeouts... |
So it turns out that the |
This is by design. This isn't really isolated to TUnit either. There isn't really a way to abort threads other than requesting cancellation and then honouring it. TUnit attempts to shut down early but it's entirely possible the original test method could still be executing in the background if it didn't honour any cancellations. So I don't know what to suggest here other than use the cancellation token given to you. Aborting threads is a no-no (also TUnit doesn't start threads manually, it leverages the standard thread pool) |
Sadly, as the thread lives forever once the exception is thrown, using the cancellation token appears to have no impact. Guess I’ll dig into the MSTest code before bed!
|
I'll need a repro to try and investigate myself, as like I said I'm unfamiliar with it. But if you can provide a simple repro repo then I'll be happy to take a look |
The toy example I provided should be suitable for reproducing the error and cannot leverage a cancellation token. Even if the nested code could use it, when a cyclical exception is thrown (in this case by the MS pipeline library AFAIK) the code that is preventing the test from completing is not in the user's control. |
This seems to hang in NUnit too by the way |
Got you. I think we need to leave this in the hands of the Microsoft.Testing.Platform guys, as they'll need to tweak how they handle the JSON serialization |
Dotnet have closed the issue as by design, and it happens on the throw so it's not TUnit related. Closing |
|
Just looped back around to this. Seems the exception theory was incorrect, will have to find time to dig into this more. Ultimately I'm not using reflection and when I run my test suite with TUnit it hangs forever, but it does not with XUnit. I'm assuming it's TUnit or the testing platform causing the issue as they're the only things being swapped out, but I don't have time to keep trying to test it to figure out what exactly is going on. If you have any tips on debugging the infinite running of certain tests (I can't share the tests) please let me know, there is an issue, I was just wrong about the cause. |
Not sure what to suggest. If it's only happening on a subset of tests, try and figure out what those tests have in common that others don't? In order for me or Microsoft to fix, it'll be much easier if we have a repro. We don't need your exact test but if you can make a new test without sensitive data that reproduces the problem then we can likely solve it. |
In VS I'm in debug mode, when I debug the test it seems to execute just fine, 100% of the time, when I run the test and the resiliancepipeline throws a couple of exceptions (for the multiple failures) it just spins forever (I left a 1 second test for many minutes to check this) unwinding a stacktrace. This did not happen when I was using the non-preview version of VS and XUnit, only when I ported to Preview with TUnit.
Running via dotnet test shows the stacktrace being written to the console for over 5 minutes.
I've speculatively included information I think may be helpful, let me know if I can provide something else.
TUnit Version: 0.2.26
Operating System: Windows 10 Pro
Visual Studio Version: 2022 (640bit) - Preview (17.12.0 Preview 4.0)
.NET Version: net8.0
Extensions: The only installed extension is ReSharper, I disabled this and the test still failed in the same way.
The Test:
TestData in base class
Generated Test Hooks:
Generated Tests:
The text was updated successfully, but these errors were encountered: