-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Fix WatchService tests #3518
Fix WatchService tests #3518
Conversation
Signed-off-by: Jan N. Klug <github@klug.nrw>
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.
Thanks for having a look!
According to the GHA build result testFileInWatchedSubDir
is unstable:
[ERROR] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 67.61 s <<< FAILURE! - in org.openhab.core.internal.service.WatchServiceImplTest
[ERROR] org.openhab.core.internal.service.WatchServiceImplTest.testFileInWatchedSubDir Time elapsed: 8.051 s <<< FAILURE!
java.lang.AssertionError:
Expected: an empty collection
but: <[Event[path=subDir/testFile, kind=MODIFY]]>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
at org.openhab.core.internal.service.WatchServiceImplTest.assertNoEvent(WatchServiceImplTest.java:192)
at org.openhab.core.internal.service.WatchServiceImplTest.testFileInWatchedSubDir(WatchServiceImplTest.java:113)
I've seen that. But even with a CPU count of 32 and a |
I have now done more than a dozens of local builds and ten GHA builds. Local builds never failed and both failures of GHA builds occurred on How shall we proceed? |
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.
Thanks! Let's give it a test and see how stable they are. Maybe it only fails 0.01% of the time and we were just unlucky the first time around. 😉
Bad luck stroke again, see: https://github.com/openhab/openhab-core/actions/runs/4604346508 |
The storage thing is that the file from which the event originates According to the documentation of the surefire-plugin tests within one class are not executed in parallel when "reuseForks=false" unless you explicitly specify "parallel=methods", so another test (that creates this file) should not interfere. Also a new temp dir should be created for each test, because Edit: sorry. It failed in a different test this time. The file is from that same test. I'll have another look. |
Yes, that's the same. |
@wborn Do you think that it is possible that In that case we should remove that check, it's anyway not checking our implementation but the watcher library. |
Wouldn't that mean that the watch service sends two MODIFY events, causing things to re-load twice? |
Depends. I believe what happens is:
So unnecessary reloading only occurs when a file is written with the same content twice AND the file system reports two events for that AND there is a time between those writes that is longer than the collapse event timeout of 1s. |
Have you tried to log this to check that this was the case? |
Difficult, because it does never happen on my system :-). It may be filesystem dependent. I'll try to add logging and push that so we can see if it fails in CI with logging enabled. |
Bingo.
|
Signed-off-by: Jan N. Klug <github@klug.nrw> GitOrigin-RevId: ee392e8
See #3516