Repository navigation
improve stability of FileSystemWatcher tests - #40543
Conversation
JeremyKuhne
left a comment
There was a problem hiding this comment.
Just a nit on the conditional fact attribute
|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
| [Fact] | ||
| public void FileSystemWatcher_File_Create_ExecutionContextFlowed() | ||
| { | ||
| ExecuteWithRetry(() => |
There was a problem hiding this comment.
Why are you removing the retry?
There was a problem hiding this comment.
I try to explain it description. It does nothing for cases where we fail on assert. And that is 100% failures I've seen with those tests.
There was a problem hiding this comment.
And that is 100% failures I've seen with those tests.
Really? We've added such retries in the FileSystemWatcher tests because the underlying functionality in the OS can be lossy. I'm concerned that by removing these retries, we'll find a new sporadic failure mode emerge.
There was a problem hiding this comment.
The problem is that in such cases we hit assert to get event. And in such cases the retry logic does not kick in anyway. I was originally expecting to see retry with failures.
ExecuteWithRetry:()
...
catch (Exception e) when (!(e is XunitException) && retry < maxAttempts - 1)There was a problem hiding this comment.
Then isn't the fix to change how we handle that failure, rather than getting rid of the retries? Or to remove that clause from the catch?
There was a problem hiding this comment.
I was thinking about retrying also with XUnit exception. As part of my tries I did that to see if the retry would actually make tests more stable. And it did but I still saw some failures.
Without the FileSystemWatcher_CreateManyConcurrentWatches I did thousands of runs without seeing any failure. This may not be representative of all CI systems but my current think is to give it try without retries. (and it is already unstable outerloop test) I can watch test result database and investigate if we see failures.
There was a problem hiding this comment.
Ok. Please put the retries back if you see any failures they could have prevented.
There was a problem hiding this comment.
yes, I will. My goal is to get outerloop green most of the time. And I can see test history via Kusto query.
| { | ||
| public abstract partial class FileSystemWatcherTest : FileCleanupTestBase | ||
| { | ||
| private const string DangerousTestEnvName = "COREFX_IO_RUNDANGEROUSTESTS"; |
There was a problem hiding this comment.
This is basically going to mean these tests are never run.
Is the goal here really to avoid running them in CI? There's a trait for that specifically.
There was a problem hiding this comment.
Would that report it is skip to test result database or would it just not run silently? I know we do not pay attention that this yet but that may impact reporting in future. Also that still leaves possibly for other test failing randomly for developers.
| [Fact] | ||
| [ConditionalFact(nameof(RunDangerousTests))] | ||
| [PlatformSpecific(TestPlatforms.Linux)] // Reads MaxUsersWatches from Linux OS files | ||
| [OuterLoop("This test has high system resource demands and may cause failures in other concurrent tests")] |
There was a problem hiding this comment.
Did you try the xunit feature that's supposed to let a test run serialized even if the rest of the tests are allowed to run in parallel with each other?
There was a problem hiding this comment.
No, I have not. I'm somewhat concern that this impacts rest of the system beyond other tests . That is reason why I wanted to make the skip somewhat more visible.
There was a problem hiding this comment.
I moved this to separate no-parallel class instead of making this conditional. That can still possibly break some OS functions but it should not impact other tests as they will not run at the same time.
|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
|
I end up disabling parallelization for the one test exhausting all available watchers. |
| { | ||
| _output.WriteLine($"Watcher failed: {e.GetException()} source={source} {source.GetHashCode()}"); | ||
| // Repeat on Console so it easier to triage in CI. | ||
| Console.WriteLine($"Watcher failed: {e.GetException()} source={source} {source.GetHashCode()}"); |
There was a problem hiding this comment.
Nit:
string msg = $"Watcher failed: {e.GetException()} source={source} {source.GetHashCode()}";
_output.WriteLine(msg);
Console.WriteLine(msg);|
/azp run |
|
Azure Pipelines successfully started running 4 pipeline(s). |
* improve stability of watcher tests * feedback from review * more feedback * disable parallelization for dangerous tests * enable FileSystemWatcher_File_Create_ForceLoopRestart again * feedback from review
* improve stability of watcher tests * feedback from review * more feedback * disable parallelization for dangerous tests * enable FileSystemWatcher_File_Create_ForceLoopRestart again * feedback from review
|
We did not see Linux failure since this was submitted. There are still OSX failures. I'll take another look as underlying reason may be different. |
* improve stability of watcher tests * feedback from review * more feedback * disable parallelization for dangerous tests * enable FileSystemWatcher_File_Create_ForceLoopRestart again * feedback from review Commit migrated from dotnet/corefx@e8fd893
This is attempt to stabilize FileSystemWatcher test. There were ~400 failures in last 90 days and I could primarily reproduce failure of FileSystemWatcher_File_Create_WatchOwnPath and FileSystemWatcher_File_Create_NotAffectEachOther.
I originally tinker with delays and timeouts. That look like improvement but tests were still failing and I could not get past 1000 runs without failure. I could not reproduce it with running single test or while running under
strace.At some point I used
inotify-toolsand provided some clues:The "no space" message is confusing as it suggests tests exhausted /tmp space. However
inotify_add_watchcan fail withENOSPCif user limit is reached. Our implementation treats that as special and instead of throwing it will call Error delegate. So I added one and sure enough the error would show up:With that I look back at the
inotifywaitfailure and FileSystemWatcher_CreateManyConcurrentWatches test:That test already claims it can impact other tests and it does. It creates situation where user limit is exhausted and then any other test (or any other independent application) can silently fail. Without that test I could pass 5000 outerloop runs without any failure!
It seems like this test is for interesting boundary condition but even if all tests are executed with parallelism, it can negatively impact other processes on system. So I made change to make it visible and easy for developer to run it as needed:
Hopefully the hint would be enough to hint to env variable.
As part of this I was also curious why the retry did not work since this is rare condition. The answer is very simple as it excludes all XUnit exception so when we fail Assert it does nothing. Since it looks like confusing useless craft I decided to remove it from test sets I was working on. Instead I left OnError callback so we would have some visibility to failures.
fixes #38815
fixes #34361