Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

FileSystemWatcher fixes and test changes #8231

Merged
merged 2 commits into from
May 9, 2016
Merged

FileSystemWatcher fixes and test changes #8231

merged 2 commits into from
May 9, 2016

Conversation

ianhays
Copy link
Contributor

@ianhays ianhays commented May 2, 2016

Fixes to FileSystemWatcher tests to increase their reliability.

  • Filtering on the OSX FileSystemWatcher was letting through events that should have been filtered out due to the passed NotifyFilters. The first commit fixes this.
  • Reworks the FSW tests to be 100% passing.
  • Adds path validation to most tests.
  • Adds a Retry mechanism to handle expected intermittent failures due to untrustworthy underlying API calls. The tests pass without it but it's a good fallback in case the CI gets bogged down and our tests start failing due to expired wait times.
  • Adds more test cases to NotifyFilter and splits existing tests into separate dir/file tests to cover either behavior.

resolves #1165
resolves #1657
resolves #2011
resolves #2684
resolves #3215
resolves #3630
resolves #4916
resolves #5306
resolves #6226
resolves #6241
resolves #6732
resolves #7002
resolves #8023
resolves #8024
resolves #8154

@ianhays
Copy link
Contributor Author

ianhays commented May 3, 2016

I resolved the issues with OSX providing bogus Created events and ran the tests a few hundred times to (hopefully) catch any intermittent failures. The only failure I got was a timeout in the old unit tests that I mostly didn't touch, so I'm going to call this ready to merge (pending feedback).

@stephentoub @hughbe @sokket

flags = FSEventStreamEventFlags.kFSEventStreamEventFlagItemInodeMetaMod |
FSEventStreamEventFlags.kFSEventStreamEventFlagItemFinderInfoMod |
FSEventStreamEventFlags.kFSEventStreamEventFlagItemModified |
FSEventStreamEventFlags.kFSEventStreamEventFlagItemChangeOwner;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: the alignment here and below looks a bit off

@ianhays
Copy link
Contributor Author

ianhays commented May 5, 2016

Thanks for the great feedback, Steve! I pushed an update with responses to all of your comments.


// Verify Changed
bool Changed_expected = ((expectedEvents & WatcherChangeTypes.Changed) > 0);
bool Changed_actual = changed.WaitOne(WaitForExpectedEventTimeout);
Copy link
Member

Choose a reason for hiding this comment

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

We're waiting on the changed event even if a changed event may not be asked for? Won't that introduce unnecessary delays into the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes to both questions. We wait for all events to ensure they are thrown (or not thrown) as expected. To make up for this, event waits after the first Changed are done using a shorter timeout value (10 ms vs 50 ms for Changed).

All of the timeout values are much lower than they were before this PR (30000/500 ms for expected/unexpected before) so there's still a net decrease in execution time. Adding the retry functionality lets us use a lower timeout without worrying as much about failures from CI machine slowdown, so the average execution is going to be faster.

I wouldn't say they're unnecessary delays though; we should be verifying that a test isn't throwing an unexpected event type.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, sounds reasonable, thanks.

@ianhays
Copy link
Contributor Author

ianhays commented May 9, 2016

@stephentoub any final feedback before I merge this?

@ianhays
Copy link
Contributor Author

ianhays commented May 9, 2016

Innerloop OSX Debug Build and Test :

08:40:49 [xUnit] [INFO] - Converting '/Users/dotnet-bot/j/workspace/dotnet_corefx/master/osx_debug_prtest/bin/tests/Unix.AnyCPU.Debug/System.Text.Encoding.CodePages.Tests/dnxcore50/testResults.xml' .
08:58:33 [xUnit] [ERROR] - The plugin hasn't been performed correctly: Problem on deletion
08:58:33 
Build step 'Publish xUnit test result report' changed build result to FAILURE

Ian Hays added 2 commits May 9, 2016 11:20
- Filtering on the OSX FileSystemWatcher was letting through events that should have been filtered out due to the passed NotifyFilters.
- The OSX FSW likes to set the Created flag for pretty much every event it throws. We explicitly disabled coalescing, so we can safely ignore that flag when it's combined with an actual flag that indicates a change.
Reworks the FSW tests to be 100% passing.
- Adds path validation to most tests.
- Adds a Retry mechanism to handle expected intermittent failures due to untrustworthy underlying API calls.
- Adds more test cases to NotifyFilter and splits existing tests into separate dir/file tests to cover either behavior.
- Enable test parallelization
@stephentoub
Copy link
Member

any final feedback before I merge this?

go for it

@ianhays
Copy link
Contributor Author

ianhays commented May 9, 2016

Thanks, Steve.

@ianhays ianhays merged commit acd7df3 into dotnet:master May 9, 2016
@karelz karelz added the os-linux Linux OS (any supported distro) label Mar 8, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
FileSystemWatcher fixes and test changes

Commit migrated from dotnet/corefx@acd7df3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.