Skip to content

Conversation

NickCraver
Copy link
Collaborator

Upgrading xUnit to v3 to see if this helps our stability issues any. This runs as an executable making profiling much easier as well, so lends itself better to investigating bottlenecks.

@NickCraver
Copy link
Collaborator Author

@mgravell FYI: Seeing if I can get this more stable - found we were spending a lot of time in dispose due to waiting on the quits, but also figured xunit v3 was much easier to profile and such.

Copy link
Collaborator

@mgravell mgravell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me

@mgravell
Copy link
Collaborator

Hey @NickCraver - what's the status of this one? I just don't want to get into massive merge hell. Anything I can do to help?

@NickCraver
Copy link
Collaborator Author

@mgravell Just running a few suites but I think this makes life better but doesn't solve the stability issues from CI (appears to be net neutral there). It makes profiling way easier though - if you're good here 👍

@NickCraver NickCraver marked this pull request as ready for review July 18, 2025 23:54
@NickCraver
Copy link
Collaborator Author

Actually - tweaking a few things based on more findings - don't sweat this, I'll eat the merge in.

@mgravell
Copy link
Collaborator

I'll eat the merge in

Screenshotting this for when you book a flight to convey your regrets mano-a-mano.

@NickCraver NickCraver marked this pull request as draft July 19, 2025 13:55
@NickCraver
Copy link
Collaborator Author

@mgravell Okay realized a big case: shared connection fixture was inadvertently connecting all tests to cluster if any cluster on a Create() ran first due to GetConfiguration() being per-class. Adding some guards and working on stability. I also need to get with Brad/VSTest folks about a problem navigating from test explorer in xUnit v3 latest:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at EnvDTE.ItemOperations.OpenFile(String FileName, String ViewKind)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Internal.TestWindowViewModel.<<OnNavigationRequested>b__140_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__12.MoveNext()
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at EnvDTE.ItemOperations.OpenFile(String FileName, String ViewKind)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Internal.TestWindowViewModel.<<OnNavigationRequested>b__140_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__12.MoveNext()
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at EnvDTE.ItemOperations.OpenFile(String FileName, String ViewKind)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Internal.TestWindowViewModel.<<OnNavigationRequested>b__140_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__12.MoveNext()
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at EnvDTE.ItemOperations.OpenFile(String FileName, String ViewKind)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenFileAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.VsHost.IOpenTargetExtensions.<OpenAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Internal.TestWindowViewModel.<<OnNavigationRequested>b__140_1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__12.MoveNext()

@NickCraver
Copy link
Collaborator Author

Also noticed that CancellationTests recent addition is pausing all clients - we should see how to better simulate that without the global pause - moving to non-parallel for now.

The script tests are another category where we're doing script and flush but the problem is the script itself is concurrently run between framework and races...could switch based on target framework/platform dynamically or something and 2 sets of scripts (1 per test suite target framework) would be enough...stupid, but effective. Will keep tweaking.

@mgravell
Copy link
Collaborator

mgravell commented Jul 19, 2025

Maybe the cancellation tests could use a decorator with fake latency / manual activation. Let me take that.

@NickCraver
Copy link
Collaborator Author

@mgravell Overall thinking of making a hostile test suite that runs separately and not parallel (with its own container/servers), but that doesn't need to happen in this PR - just aiming at equal or better. Note that xUnit v3 has an explicit test operator we can use but I think a separate assembly may be the way to go - VS kicks all off at once with shared servers is the rub to figure out.

On this I just need to at least fix AppVeyor (broken by this PR) - given how weak those servers are I'm thinking we just run net8.0 tests on AppVeyor in general, and later move packaging into Actions and remove AppVeyor altogether.

Thoughts?

@NickCraver NickCraver marked this pull request as ready for review July 19, 2025 18:04
@NickCraver
Copy link
Collaborator Author

@mgravell I suggest pulling this and see what you think locally. There's an annoying bug where clicking from test explorer doesn't go to the method - will file against xUnit but let me know if that's a blocker to merging here, you'd see it more than me coming up.

Overall, this should take you from 2min+ down to ~30sec locally and it reproduces some races we've been hunting after getting things much more parallel. I think if you select both suites and run until failure, you'll find some things I can yet fix and some very interesting races...like returning the wrong key, from another test:
image

It's not perfect yet but close on test stability and I can rev, but if it's easier to merge now and continue that, let's go that way and I'll do a follow-up. Definitely more on the table here.

@mgravell
Copy link
Collaborator

Seems fine in Rider...

image

Thanks for the effort - trying it.

@mgravell
Copy link
Collaborator

Looking great locally; a few Mono-related breaks when running as netfx, but I don't think I am going to obsess about that - even less so than netfx.

@mgravell
Copy link
Collaborator

(to be clear: those Mono breaks are not related to this PR, which runs very fast)

@NickCraver
Copy link
Collaborator Author

@mgravell I've seen this many times now - take a look at: https://github.com/StackExchange/StackExchange.Redis/pull/2907/checks?check_run_id=46350879681

 23:49:14.8058: Full info for: miscellaneous
 23:49:14.8058:   txt  ==>  # CPU
 23:49:14.8058:   used_cpu_sys  ==>  0.059433
 23:49:14.8059:   used_cpu_user  ==>  0.369478
 23:49:14.8059:   used_cpu_sys_children  ==>  0.000000
 23:49:14.8059:   used_cpu_user_children  ==>  0.001609
 23:49:14.8059:   used_cpu_sys_main_thread  ==>  0.058511
 23:49:14.8059:   used_cpu_user_main_thread  ==>  0.369911

Note the txt record, like the RESP3 processing is slightly off. I've seen it specifically on the INFO processor.

@NickCraver
Copy link
Collaborator Author

@mgravell I think this is a good pause point, will hands-off. Merge at will if you're good and I'll keep an eye on failures and help chase remaining, I think we're far net better as-is.

Copy link
Collaborator

@mgravell mgravell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing stuff, thanks

@mgravell mgravell merged commit 5f58617 into main Jul 21, 2025
8 checks passed
@mgravell mgravell deleted the craver/xunitv3 branch July 21, 2025 08:15
@mgravell
Copy link
Collaborator

super happy, thanks; PRs are no longer fighting me with false positives:

image

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

Successfully merging this pull request may close these issues.

2 participants