Erratic test failure in CachingStateRepositoryTest.testCacheExpiryBecauseOfTimeToLife

4 views
Skip to first unread message

Richard Steele

unread,
Mar 16, 2015, 8:39:19 AM3/16/15
to toggl...@googlegroups.com
I was able to build and run all of the tests cleanly last week until late Friday and continuing today, where I'm getting a single test failure in CachingStateRepositoryTest.testCacheExpiryBecauseOfTimeToLife:

-------------------------------------------------------------------------------
Test set: org.togglz.core.repository.cache.CachingStateRepositoryTest
-------------------------------------------------------------------------------
Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.675 sec <<< FAILURE!
testCacheExpiryBecauseOfTimeToLife(org.togglz.core.repository.cache.CachingStateRepositoryTest)  Time elapsed: 0.051 sec  <<< FAILURE!
org.mockito.exceptions.verification.TooLittleActualInvocations: 
stateRepository.getFeatureState(TEST);
Wanted 5 times:
-> at org.togglz.core.repository.cache.CachingStateRepositoryTest.testCacheExpiryBecauseOfTimeToLife(CachingStateRepositoryTest.java:105)
But was 3 times:
-> at org.togglz.core.repository.cache.CachingStateRepository.getFeatureState(CachingStateRepository.java:78)

at org.togglz.core.repository.cache.CachingStateRepositoryTest.testCacheExpiryBecauseOfTimeToLife(CachingStateRepositoryTest.java:105)
             .
             .
             .

If I change the Thread.sleep() on line 101 from

            Thread.sleep(ttl + 1); // wait some minimal amount of time to let the cache expire

to

            Thread.sleep(ttl + 30); // wait some small amount of time to let the cache expire

the test passes.

I'm guessing that maybe the granularity of the clock on my system is not as good as yours?  (I'm running latest update to Java 7 on a Windows 7 64-bit machine).  I can't explain though why this was passing previously.

Thoughts?

Christian Kaltepoth

unread,
Mar 17, 2015, 5:12:01 AM3/17/15
to toggl...@googlegroups.com
Hey Richard,

thanks for bringing this up. Hmmm. That's really very weird. This test runs fine on my box and also the CI build is fine. Perhaps this is really a Windows issue.

Of cause it is ok to increase the offset to 30 or even higher. That' should be fine. Could you perhaps open a pull request for this?

Christian

Richard Steele

unread,
Mar 17, 2015, 7:59:14 AM3/17/15
to toggl...@googlegroups.com
Done, created pull #123.
Reply all
Reply to author
Forward
0 new messages