fix AbstractWatchServiceTest for macOS - again #3316
Conversation
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.
Hmmmm.... I just tried it:
subdirs are registered, but dirs modifications are not watched(org.eclipse.smarthome.core.service.AbstractWatchServiceTest) Time elapsed: 10.007 sec <<< FAILURE!
java.lang.AssertionError: Exactly 1 watch events were expected, but were: []
Expected: is <1>
but: was <0>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:865)
at org.junit.Assert$assertThat$3.callStatic(Unknown Source)
at org.eclipse.smarthome.core.service.AbstractWatchServiceTest$_assertFileCreateEventIsProcessed_closure11.doCall(AbstractWatchServiceTest.groovy:289)
at org.eclipse.smarthome.core.service.AbstractWatchServiceTest$_assertFileCreateEventIsProcessed_closure11.doCall(AbstractWatchServiceTest.groovy)
at sun.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:278)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at org.eclipse.smarthome.test.OSGiTest.waitForAssert(OSGiTest.groovy:220)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:187)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:61)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
at org.eclipse.smarthome.test.OSGiTest.waitForAssert(OSGiTest.groovy:191)
at org.eclipse.smarthome.test.OSGiTest.waitForAssert(OSGiTest.groovy)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at org.eclipse.smarthome.core.service.AbstractWatchServiceTest.assertFileCreateEventIsProcessed(AbstractWatchServiceTest.groovy:289)
Did the maven build run successfully on your machine?
Mine is slightly different, but also failing:
|
* move watch directory creation/deletion before/after each test Signed-off-by: Henning Treu <henning.treu@telekom.de>
7a1f025
to
1514d73
Compare
I did another modification which creates/removes the root watch directory before/after each test case. This way the main build should also be stable now. |
@SJKA & @kaikreuzer would be nice to get some macOS user feedback - again :-) |
@htreu You have asked for it :-) The good news is:
The bad news is: The execution of just 8 tests takes 3 minutes (have a close look at the "Time elapsed" values):
|
Here again we are back at the discussion that Java (still) falls back to polling the file system on MacOS (see e.g. here). I know only two ways of improving this:
Last but not least:
|
|
@htreu Which option do you prefer? |
I would for now go with option 3 and leave it as it is. The build runs cleanly now and doing a full build&test happens not so often. The main purpose of this PR is to be able to run all test at all on macOS. |
I agree that such a long test time is not really nice, but skipping the test is IMHO not the intention of tests at all. 😉 So, for me option three makes sense. But I am not a Mac user, so I leave it up to @kaikreuzer and @SJKA. But then we should state that a CI infrastructure for ESH should not be run on a Mac. |
Ok, so I'll just have a coffee more whenever I execute the local build ;-) |
WatchQueueReader was "fixed" due to incorrect tests. This roles back the change and fixes the test.
Signed-off-by: Henning Treu henning.treu@telekom.de