-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Make System.Diagnostics.Tracing.Tests run sequentially #94324
Conversation
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti |
@davmason what does this property do - pass some flag to xunit that tells it to ignore the attribute? What is that? This is not the only test library that has those no parallelism annotations. |
@danmoseley I have no idea why the attributes are ignored, but through reverse engineering I found that this property sets maxthreads to 1 here
From my testing it seemed like if you ran |
@bradwilson any idea why the attribute is being ignored? Context: #91769 (comment) |
First: Is the console runner display broken?The display from the console runner is based on an "outside" view of what's going on; that is, it only displays what the runner has requested the test framework do (based on defaults + configuration files + command line switches). The test framework does not report back out what it's actually doing. We provided no mechanism to do that in v2: we only support outside-in communication, not inside-out communication, regarding parallelism. So the assembly-level attribute does not get reflected into the display on the console runner. That means this:
is expected behavior. The best way to get what you want is to remove the assembly-level attribute and add/update Second: Is the attribute broken?Through experimentation, I have found that the
Image deleted because it's no longer relevant
|
Actually, ignore that. I tripped myself by having a configuration file that had I now believe you can ignore the second half of what I just wrote. |
thanks @bradwilson . I realize that for some reason I had assumed that the attribute would win over any xunit.runner.json or command line flag, but apparently it's the reverse So the command line or xunit.runner.json must be overriding it. (Curiously, I'm not sure how our xunit.runner.json would have parallelizeTestCollections: true. The various layers around xunit in this repo and all the various ways it can be invoked, including a custom dummy xunit with fewer dependencies, make it hard to see, and I won't look further (eg actually run build.sh -test..)) One question though. Is there any functional difference between disabling parallelism and running with a limit of 1 thread? I guess this PR is doing the latter. |
@davmason there are 18 test libraries in the tree that have |
Yes, it's definitely the reverse, and purposefully. We presume that things you put in source define the default behavior, and you can use interactive mechanisms like command line switches to alter that default behavior. The reverse wouldn't make much sense, as you wouldn't be able to override anything in source w/o changing the source itself.
Yes. (Everything I'm about to describe is a summary of If parallelism is globally disabled, we do not create the If parallelism is globally enabled, we do create the For every parallelizable test collection, start the first test in the collection. These are all started in parallel. As each test in the collection finishes, we start the next test for that collection, until all the tests in the collection have run. Once all the tests from all the parallelizable test collections have run, then we sequentially run all the non-parallelizable test collections in a manner identical to the "parallelism globally disabled" behavior. We will effectively start running (There is an important aside here: we rely on you not escaping the sync context to ensure the limits on parallelism. That means any call to Generally speaking, people more often have a subset of tests that they want to prevent running in parallel with one another, typically because of a shared resource like a database. They use test collections and collection fixtures to coordinate that. Disabling parallelism globally is a mechanism that typically only makes sense if you have a globally shared resource and every test in your test assembly needs access to that globally shared resource. This is a pretty uncommon scenario in my experience, but not unheard of. |
Super helpful, thanks. There's some begged questions about our own infra here, but this issue will be helpful if those are actually encountered. I'm guessing that these tracing tests don't run problematic code in awaits but I can't look at the moment. |
FWIW, the Globally disabling parallelism doesn't have any effect here; it's just that the one test which may be awaiting an incomplete task will be sitting and waiting for the result, which may end up being calculated on a different thread. Even in that scenario, though, any non-parallelizable test collection (including globally disabling parallelism) means the test will just sit there and wait, while no other tests are running, rather than giving up a worker thread in the pool for another test. |
I'm also pushing up an update into the next release of the v2 core framework so that max parallel thread counts are only shown when test collection parallelization is enabled. So previously:
Upcoming:
This should add clarify about thread counts being tied into parallelism as well as a bit of brevity. |
that's helpful. what about this case |
That test is specifically about what people see without diagnostic messages enabled (that's the first The last test item in the list ( |
Fixes #91769
Fixes #91304
Fixes #88027
Apparently the
build.cmd -test
method of running tests needs a different way of disabling parallelization