Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Modify FileSystemWatcher tests to use temp paths. - #7934

Merged
ianhays merged 1 commit into
dotnet:masterfrom
ianhays:fsw_cleanup
Apr 22, 2016
Merged

ianhays merged 1 commit into
dotnet:masterfrom
ianhays:fsw_cleanup

Conversation

@ianhays

@ianhays ianhays commented Apr 20, 2016

Copy link
Copy Markdown
Contributor

This is a pretty general clean-up of the FSW tests to be more in line with the other FileSystem tests.

  • Add Common TempDirectory class for short-term temporary directories that are easy to create and destroy
  • Put all FSW tests into the System.IO.Tests namespace
  • Modify all FSW tests to use the common TempFile/TempDirectory classes instead of their own custom one
  • Modify all FSW tests to watch for events in a temporary directory. There shouldn't be any more new items being created or watched in the runtime folder.
  • Fix the SymLink tests to use the ConditionalFact attribute similar to how the FileSystem tests function.
  • Remove the symlink print statements being outputted by the FileSystem CreateSymbolicLink function.

@stephentoub

@ianhays ianhays self-assigned this Apr 20, 2016
@ianhays ianhays added this to the 1.0.0-rtm milestone Apr 20, 2016
@ianhays ianhays changed the title Modify FileSysemWatcher tests to use temp paths. Modify FileSystemWatcher tests to use temp paths. Apr 20, 2016
@ianhays

ianhays commented Apr 20, 2016

Copy link
Copy Markdown
Contributor Author

Tested these changes on Ubuntu and Windows. I'm interested to see OSX will react to them (I don't have an OSX box) but it looks like almost all of the FSW tests are already disabled on OSX for one reason or another.

After this PR I'm going to modify the way we test timeouts then re-enable every failing test and see what's still failing. It looks like most of the dozen or so FSW issues I have assigned to me right now are the result of one of two things:

  • tests watching the same directory causing race conditions
  • OS missing events

The first issue is resolved by this PR. The second is resolvable by retrying the trigger-inducing event (i.e. retrying the test). If the trigger check still fails after several tries, then we can count the test as failing. For a library as inherently prone to failure as FSW we don't need to be quite so strict in our tests.

@stephentoub

Copy link
Copy Markdown
Member

it looks like almost all of the FSW tests are already disabled on OSX for one reason or another.

Really? If that's true that's very concerning.

@stephentoub

Copy link
Copy Markdown
Member

The second is resolvable by retrying the trigger-inducing event (i.e. retrying the test). If the trigger check still fails after several tries, then we can count the test as failing. For a library as inherently prone to failure as FSW we don't need to be quite so strict in our tests.

We've talked a few times about formalizing this into some reusable xunit-based attribute. Not as part of this change, but might be something you want to look into as a replacement for this, and something that could be used elsewhere as well, e.g. with some of our networking tests.


private void DeleteDirectory()
{
try { Directory.Delete(Path, true); }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As long as you're editing/moving this, could you use a named arg for the Boolean here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure.

@stephentoub

Copy link
Copy Markdown
Member

LGTM

@ianhays

ianhays commented Apr 21, 2016

Copy link
Copy Markdown
Contributor Author

We've talked a few times about formalizing this into some reusable xunit-based attribute. Not as part of this change, but might be something you want to look into as a replacement for this, and something that could be used elsewhere as well, e.g. with some of our networking tests.

That's exactly what I had in mind actually! I was envisioning an attribute that allowed you to decorate a method as unreliable/unstable/untrustworthy with the option of specifying a maximum number of times that a test should be retried e.g.

[Fact]
[RetryTest(10)] // If the test fails, retry it up to 10 times
public void test() {..}

or maybe

[UnreliableFact(12)] // If the test fails, retry it up to 12 times
public void test() {...}

That way we could prioritize test failures differently. If we retry what was previously an unreliable test 10 times and it still fails then there's probably something actually wrong. What worries me about our current situation is that test failures in some libraries get shrugged off because of how prone to failure they are and that's leaving us open to actual product bugs getting ignored.

I'll be working on that next most likely. After this merges.

@stephentoub

Copy link
Copy Markdown
Member

That's exactly what I had in mind actually!

😄

I was envisioning an attribute that allowed you to decorate a method as unreliable/unstable/untrustworthy with the option of specifying a maximum number of times that a test should be retried

There are likely a few things someone would want to control per test, e.g. how many times to attempt a retry, what backoff to use between retries, etc. There might even be a condition someone would want to run to determine whether to retry again. I believe @CIPop was very interested in having this retry functionality... he might have some input as to what it should be able to do. I think there's also a sample in the xunit repro that does retries, so you might get some inspiration from that.

One concern is that we're starting to have a bunch of things we want to do to tests, e.g. making a test conditional, making it retriable, etc. I expect we're going to want to be able to mix-and-match those, and right now the way we do these isn't easily combinable. It'd be worth exploring what the right design is for this with xunit so that they can be used together in the future, e.g. maybe we have a single ExtensibleFact/Theory attribute that looks for other attributes on the same method to determine what to do and allows for them to be pipelined, e.g. you can make a test [ExtensibleFact] and then add one or more [Conditional(...)], [Retryable(...)], etc. attributes and they'd all be factored in. Food for thought.

In any event, I'm glad you'll be looking into it.

@ianhays

ianhays commented Apr 21, 2016

Copy link
Copy Markdown
Contributor Author

I think there's also a sample in the xunit repro that does retries, so you might get some inspiration from that.

The sample is nearly identical to the one I gave earlier so I guess thats +1 for that design.

I expect we're going to want to be able to mix-and-match those, and right now the way we do these isn't easily combinable

Yeah, I'd like to see things like ConditionalFact and ConditionalTheory as additional Conditional attributes on a Fact or Theory rather than their own distinct entities. The same should be true for the Retry attribute. I need to dive deeper into xunit because I don't know what the limitations are, but that would be ideal.

I've opened an issue for this in buildtools: dotnet/buildtools#654

@ianhays

ianhays commented Apr 21, 2016 •

Copy link
Copy Markdown
Contributor Author

it looks like almost all of the FSW tests are already disabled on OSX for one reason or another.

Really? If that's true that's very concerning.

It was a vast overstatement. We've got about 15 of the tests disabled for OSX for one ActiveIssue or another.

edit: out of ~90 total tests.

@ianhays

ianhays commented Apr 21, 2016

Copy link
Copy Markdown
Contributor Author

test Innerloop OSX Debug Build and Test please

- Add Common TempDirectory class for short-term temporary directories that are easy to create and destroy
- Put all FSW tests into the System.IO.Tests namespace
- Modify all FSW tests to use the common TempFile/TempDirectory classes instead of their own custom one
- Modify all FSW tests to watch for events in a temporary directory. There shouldn't be any more new items being created or watched in the runtime folder.
- Fix the SymLink tests to use the ConditionalFact attribute similar to how the FileSystem tests function.
- Remove the unnecessary symlink print statements being outputted by the FileSystem CreateSymbolicLink function.
@ianhays
ianhays merged commit d148893 into dotnet:master Apr 22, 2016
@ianhays
ianhays deleted the fsw_cleanup branch May 18, 2016 15:45
@karelz karelz modified the milestones: 1.2.0, 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Modify FileSystemWatcher tests to use temp paths.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants