-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Make xUnit test run sequentially to rule out race conditions around 'powershell.config.json' #8945
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
Conversation
…powershell.config.json'
|
@daxian-dbw Can you tag all the issues open for xunit tests in this PR? |
|
@adityapatwardhan I tagged #8784 #8715. Please let me know if there are others. |
| - powershell: | | ||
| Import-Module .\tools\ci.psm1 | ||
| $ParallelXUnitTestResultsFile = "$(System.ArtifactsDirectory)\xunit\ParallelXUnitTestResults.xml" | ||
| $xUnitTestResultsFile = "$(System.ArtifactsDirectory)\xunit\xUnitTestResults.xml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do something smarter here. Like:
- Get all items in the
xunitfolder - run
Test-XUnitTestResultson each item found - or throw an exception if no items were found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, this is not changed frequently. So, this is not blocking this PR.
|
I very wonder why we mask BUGs which are revealed by the tests? I expect that we fast fix the bugs:
|
This is not hiding bugs, but to fix our test script. Blindly running all xUnit tests in parallel is just wrong. Please take a look at the original script in The categorization was for a reason -- config files get created and deleted in I could make the test script behave like before -- running
Be noted that, fixing the test script doesn't mean we don't want to fix the race condition issue regard to processing the config file.
@TravisEz13 and I chatted about this offline and we believe this is not a release blocker because it's already an existing issue.
The 9% failure was because of the frequent creation/deletion of the config files within |
I am 😄 that the team will keep it under control. Thanks! One extra note that if I hadn’t made these tests parallel, we wouldn’t start fixing these race conditions. I do not know how now we can identify such problems (?) |
The flag |
We have so many open issues that it is easy to lost/forget important ones. It is difficult to prioritize work. And it seems GiHub doesn't help well. :-( |
This problem is too rarely raised and running the tests in parallel is useless locally. Can we do it on CI (maybe optional) to track the race conditions? |
Like I said previously, fixing the race condition won't help to make our test reliable if they are running in parallel, because the setting values returned are not predictable. A test may expect a specific value for a setting but instead get back the default value due to race condition and thus would fail. It should be tracked by an issue.
It's rarely raised because it rarely happens in real scenarios, and that's likely why the this issue has not been treated with high priority. |
In long term yes. For now my suggestion was to create optional CI job (like CodeFactor or Codacy) so that we can track the state of affairs until we find better solution. |
Rather, because PowerShell is rarely used. If we imagine that it would be used in high-load application such as Microsoft SCOR we would catch a bunch of unpredictable crashes. Or in multi-user system like Misrosoft Remote Desktop any regular user would block all system scripts by locking the config file! |
You could do the same to any applications. So, yes, it's technically a DoS attack, but if a user is able to do it (has the permission), then there's always a way for him/her to do it, no matter we fix the race condition regarding |

PR Summary
Make xUnit test truly run sequentially to rule out race conditions around
powershell.config.json.Fix #8784 #8715
PR Context
We keep getting xUnit test failures due to the race condition around manipulating
powershell.config.jsonfile, even though we have been trying to run xUnit tests sequentially by havingdotnet test -p:ParallelizeTestCollections=false. It turns out-p:ParallelizeTestCollections=falsedoesn't work, and we have to usexunit.runner.jsonto disable parallel running.Failure example: https://powershell.visualstudio.com/PowerShell/_build/results?buildId=13830
From the exception below, we can see the all-user scope config file was there when we check for file existence in
ReadValueFromFile, but was deleted when we came to creating aFileStreamout of it.This is because the all-user scope config file as created and deleted as part of the
PSConfigurationtests. This is an evidence that tests are still running in parallel withdotnet test -p:ParallelizeTestCollections=false.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.[feature]to your commit messages if the change is significant or affects feature tests