-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
tests: refactored fs watch_dir tests for stability #480
Conversation
a51b3a8
to
7153f45
Compare
One thing I forgot to mention, or maybe it wasn't clear, is that the original test appeared to do four cycles of creating files and then removing the files. This current PR only does one cycle but updating it to do four should be trivial. It's your call as to whether I add the extra cycles back or not. |
I'm afk until Monday. Will take a look then! Thanks!
|
fs_event_unlink_files(handle); | ||
} else if (fs_event_cb_called == fs_event_created + fs_event_removed) { | ||
/* Once we've processed all create and delete events, stop watching */ | ||
ASSERT(0 == uv_fs_event_stop(handle)); |
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.
This is not really necessary, since calling uv_close
will trigger a stop.
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.
Makes sense. I didn't write the original test so I didn't want to change it but I will remove it if you think it's unnecessary.
Not sure if it was failing before, but SmartOS and FreeBSD are failing: SmartOS:
FreeBSD:
|
I will remove the unnecessary stuff and test on the other environments. I will update you. |
Thanks! Ping me me if you need me to trigger the CI. |
7153f45
to
6af56f8
Compare
I have updated the PR. I removed my debugging output (sorry), removed the unnecessary assertions @saghul mentioned and updated the assertion in the |
I've found something. On FreeBSD (#128) and SmartOS, the tests were failing prior to this PR. But after looking at the CI environment, it seems something changed for |
6af56f8
to
2c80133
Compare
I've cleaned up the sources a little to remove some compiler warnings on non-OSX/Windows. Progress: FreeBSD FreeBSD was failing prior to this PR but I wanted to see if there was something I could do about it. What I've noticed is that the fs event callback CentOS Building an environment as we speak. No idea why it would stop passing due to these changes but I'll find out soon enough. SmartOS SmartOS was failing prior to this PR as well and it has similar symptoms to FreeBSD. I will circle around to SmartOS when I make progress on one of the environments above. |
5da99b1
to
edcb386
Compare
I've merged in |
I just tested locally on CentOS 7 and |
I think we're back in the state we were prior to this PR. FreeBSD and SmartOS are failing as they were before and I think it might be a bigger issue not related to the previously flaky tests. @saghul Can you kick off a new CI build to make sure CentOS 7 is passing again? |
Thanks again for the effort you're putting on this. I'll trigger the CI as
|
No problem. If you get a few minutes when you get home, ping me in IRC so we can chat. |
I have investigated the FreeBSD side. I'm afraid this is just how it works: it coalesces events into one I think we could do following thing - make it create and unlink files in different event-loop ticks. Does it make sense? |
Yes. I will update the PR when I've got that approach implemented. Thanks for your help. |
1506476
to
a124253
Compare
The latest version of the PR has Once @indutny verified that the fs event callback As it stands, this PR not only makes the |
@whitlockjc sorry, yesterday ended up not working for me. CI: https://jenkins-iojs.nodesource.com/view/libuv/job/libuv+any-pr+multi/133/ |
@whitlockjc can you please rebase again? I pushed a fix for the broken build on Windows. |
fs_event_watch_dir and fs_event_watch_dir_recursive could fail randomly due to the way in which the tests were written. Originally timers were used to create, remove and recreate the test files but this could lead to a race condition if the timeout used to delete the test files ran before all file creation fs events were handled. On top of that, the file removal timer scheduled another timer to recreate the test files and that timer's timeout could also lead to the same condition. The refactoring removed timers for the removal/recreation of the test files and instead the fs event callback was updated to have the necessary logic to drive the test file removal. We no longer recreate the test files since it appears to be unnecessary. Fixes libuv#30
a124253
to
f58ea51
Compare
Done. |
Great job @whitlockjc! LGTM 👍 |
Thanks to all that helped: @indutny and @misterdjules Two excellent mentors. |
fs_event_watch_dir and fs_event_watch_dir_recursive could fail randomly due to the way in which the tests were written. Originally timers were used to create, remove and recreate the test files but this could lead to a race condition if the timeout used to delete the test files ran before all file creation fs events were handled. On top of that, the file removal timer scheduled another timer to recreate the test files and that timer's timeout could also lead to the same condition. The refactoring removed timers for the removal/recreation of the test files and instead the fs event callback was updated to have the necessary logic to drive the test file removal. We no longer recreate the test files since it appears to be unnecessary. Fixes: #30 PR-URL: #480 Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Landed in ✨ 8326470 ✨ Much obliged, @whitlockjc! |
WOOHOO! |
fs_event_watch_dir
andfs_event_watch_dir_recursive
could fail randomlydue to the way in which the tests were written. Originally timers were
used to create, remove and recreate the test files but this could lead
to a race condition if the timeout used to delete the test files ran
before all file creation fs events were handled. On top of that, the
file removal timer scheduled another timer to recreate the test files
and that timer's timeout could also lead to the same condition.
The refactoring removed timers for the removal/recreation of the test
files and instead the fs event callback was updated to have the
necessary logic to drive the test file removal. We no longer recreate
the test files since it appears to be unnecessary.
With the current PR, I can run 1000 tests for
fs_event_watch_dir
andfs_event_watch_dir_recursive
without a single failure, where prior to thisPR they would fail 14/100 on average.
Fixes #30